This will give 1 if the βtestβ is in the comparison set 1 or more times, or 0 if it is not.
SELECT CAST(COUNT(*) AS BIT) as IsItHere WHERE 'test' IN('not','in','here')
Please note that the cast is not strictly necessary, but can be useful if it is called from another language ... Then it must be solved in a logical way.
EDIT: According to the MSSQL query planner, this runs 4 times faster than the CASE method. YMMV.
source share