Thursday, March 29, 2012

CASE statement using wildcard

im trying to use wildcard in CASE statement with no luck.

im use this:

SELECT CASE tb001
WHEN '%price%' then 'Price'
ELSE 'No price'

the colum is varchar

The expected result would be 'Price' in every row that contains price (with wildcard around) but every line shows 'No price'
Everything works fine if i don't use wildcard and put in the whole string.

thx in advance //MrTry (not tested)
SELECT
CASE
WHEN tb001 like '%price%' then 'Price'
ELSE 'No price'
END
FROM ...|||works like charm... thx alot

No comments:

Post a Comment