I work on SQL server 2012 I face issue on code below when
EStrat value is
number as sample >1000 or <1000 or =1000 as sample it working good
because it will use AcceptedValuesOption_Value and this field is integer so no issue on that
issue happen when EStrat value is <>'Solid State Relay' or ='Solid State Relay'
so it will use field AcceptedValuesOption_Value and this field is integer so it is wrong and it will stuck
correct is when EStrat value is <>'Solid State Relay' or ='Solid State Relay' use Name
so How to correct statement below to do that
SET @ConStr= STUFF((SELECT CONCAT(' Or (PM.ZfeatureKey= ', CC.ZfeatureKey , IIF(CC.ZfeatureType='Qualifications',' And AcceptedValuesOption_Value ' ,' And ' + case when PATINDEX('%[><=]%', EStrat)>0 then
'AcceptedValuesOption_Value '
when EStrat is null then
'Name '
else
'Name '
end ) , case when PATINDEX('%[><=]%', EStrat)>0 then
CAST(EStrat AS NVARCHAR(2500))
when EStrat is null then
' is null '
else
''+CAST(EStrat AS NVARCHAR(2500)) +''
end ,')')
What I have tried:
SET @ConStr= STUFF((SELECT CONCAT(' Or (PM.ZfeatureKey= ', CC.ZfeatureKey , IIF(CC.ZfeatureType='Qualifications',' And AcceptedValuesOption_Value ' ,' And ' + case when PATINDEX('%[><=]%', EStrat)>0 and isnumeric(EStrat)=0 then