In the query below I would expect the OR CONTAINS(d.Data, @SearchText)
never to be reached due to @SearchText
being set to NULL
. However running this query throws a
"Null or empty full-text predicate."
error because the CONTAINS(d.Data, @SearchText)
is called with a null value for @SearchText.
Any ideas why the second part of the OR statement is called when the first part is true?
DECLARE @searchText nvarchar(300);
set @SearchText = null
SELECT * FROM Person p
JOIN PersonDocument pd ON p.Id = pd.PersonId
JOIN Document d ON d.Id = pd.DocumentId
WHERE @SearchText IS NULL OR CONTAINS(d.Data, @SearchText)