SQL Server: use CASE with LIKE

Add an END before alias name.

CASE WHEN countries LIKE '%'+@selCountry+'%' THEN 'national' 
     ELSE 'regional' 
     END 
AS validity

This is the syntax you need:

CASE WHEN countries LIKE '%'+@selCountry+'%' THEN 'national' ELSE 'regional' END

Although, as per your original problem, I'd solve it differently, splitting the content of @selcountry int a table form and joining to it.


You can also do like this

select *
from table
where columnName like '%' + case when @varColumn is null then '' else @varColumn end  +  ' %'