Trying to setup a SQL stored procedure that if the variable passed to it equals the keyword ‘All’ It negates the column ‘PlatformName’ from the WHERE clause and returns everything in PlatformName and the variable in @Title.
My SQL code is below.
WHERE PlatformName = CASE @Platform
WHEN 'All' THEN ''
ELSE @Platform
END
AND Title LIKE '%' + @Title + '%'
The ” is not returning anything.
Table PlatformName Title XBox 360 Foobar PS3 Foobar
One way to do exactly what you are trying to do is:
Another common way you’ll see used is:
I’d recommend testing those for performance.