i have sql sintax :select col1, case when a = '12' or b = 'A' then x.quantity else 0 end as totfrom table1 as x
and than i want to create that to storeprocedure with conditionif col1 <> '' then ' where col1 = 'ABC'end ifi use this sintax in procedure : declare @sql varchar(1000);select @sql = 'select col1, case when a = '12' or b = 'A' then x.quantity else 0 end as totfrom table1 as x';if (@sql) begin select @sql = @sql + ' where col1 = 'ABC'; endexec (@sql)
but, the problem at case when a = '12' or b = 'A'
because i use ' characterhow to fix this problem ? thank you :)programming