I have been breaking my head over this hope it’s possible
declare @locationType varchar(50);
declare @SearchTerm NVARCHAR(100);
SELECT column1, column2
FROM whatever
WHERE
CASE @locationType
WHEN 'location' THEN account_location LIKE @SearchTerm
WHEN 'area' THEN Area LIKE @SearchTerm
WHEN 'division' THEN xxx_location_division LIKE @SearchTerm
END
I copied the code form another related post here.
I get the error:
Incorrect syntax near the keyword ‘LIKE’.
Make sure that
@SearchTermstarts with/end with%-> or use'%' + @SearchTerm + '%'.More info on LIKE operator.
— Update —-