I need to check if there is a specific sequence of characters in a select and if so, indicate the case by setting a variable.
This is what I tried:
SELECT
@FLAG = CASE
WHEN '%ABC%' IN (SELECT [COLUMN]
FROM [TABLE]
WHERE [CONDITION])
THEN 1
ELSE 0
but it doesn't work because the @FLAG
result is always "0"
(the output of the SELECT is a list of rows)
1条答案
按热度按时间kiz8lqtg1#
You should change your criteria to use
EXISTS
, likeunless you are interested to find records where
[COLUMN]
is exactly'%ABC%'