I have a basic SQL query, starting with:
SELECT top 20 application_id, [name], location_id FROM apps
Now, I would like to finish it so that it
Assuming @locid & @lid are the same, I'm going to use @locid... The following would work. I've split it up to keep it looking good on SO.
SELECT application_id, [name], location_id
FROM apps
WHERE
(
@locid = 0
OR
CHARINDEX
(
',' + CAST(location_id AS VARCHAR(50)) + ','
,
',' + @locid + ','
,
0
) > 0
)