I'm trying to test some logic I want to include in a SQL query I have.
I want to be able to check against a group of values when a user sets a parameter value (location). I tried the query below but get no results, and I know why. The number values I have below need to have quotes around each number, but I can't do that because then the sql statement becomes invalid and I get an error:
Server: Msg 170, Level 15, State 1, Line 6
Line 6: Incorrect syntax near ','.
Any help would be appreciated.
I want to be able to check against a group of values when a user sets a parameter value (location). I tried the query below but get no results, and I know why. The number values I have below need to have quotes around each number, but I can't do that because then the sql statement becomes invalid and I get an error:
Server: Msg 170, Level 15, State 1, Line 6
Line 6: Incorrect syntax near ','.
Code:
DECLARE @location as char(1) SET @location = 'B' select * from smsdss.encv f where cast(f.hpohierhpoobjid as varchar(25)) IN (case when @location = 'B' then ('1004088425,1002573976,1003204285') else null end)
Comment