Let’s say I have this SQL query:
declare @input varchar(20)
select *
from myTable
where CONTAINS (myColumn, ISNULL(@input, 'replacement text'))
If I try to execute this, I get an error that says “Incorrect syntax near ‘ISNULL’.” I know that this is the correct syntax for ISNULL. Is there a reason why the ISNULL cannot be called inside of the CONTAINS statement?
try this:
it is the same problem when you try to put an expression into a stored procedure call:
CONTAIN expects a string literal, see CONTAINS (Transact-SQL)