I'm attempting to write something like:
SELECT Id FROM SomeTable
WHERE
CASE WHEN (@param IS NULL) THEN
1
ELSE
CONTAINS([FullText],@param)
END = 1
but I can't seem to get SQL Server not to complain about the syntax. Is there a way to use CASE to short-circuit the CONTAINS search?
Even doing something like this doesn't seem to short-circuit:
CASE WHEN (@param IS NULL) THEN
1
ELSE
(CASE WHEN CONTAINS([FullText], @param ) THEN
1
ELSE
0
END)
END = 1