Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Can I use like in a case statement?

Author  Topic 

memarcie
Yak Posting Veteran

91 Posts

Posted - 2007-09-27 : 11:15:32
I want to check if the value 'REPRICE' is in the filename_out field. This syntax just checks for the exact value, so I get no results. I tried like and I get a syntax error. Can I use this?


Select filename_out, type,
case filename_out
when '%REPRICE%'
THEN 'Misdirect'
else ' '
end as type
from filenames

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-09-27 : 11:20:43
[code]Select filename_out, type,
case When filename_out like '%REPRICE%' THEN 'Misdirect'
else ' '
end as type
from filenames[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

memarcie
Yak Posting Veteran

91 Posts

Posted - 2007-09-27 : 11:21:51
To clarify, 'REPRICE' is just part of the filename I'm looking for. the value will be something like aaabbbcccReprice_name.
Go to Top of Page

memarcie
Yak Posting Veteran

91 Posts

Posted - 2007-09-27 : 11:23:11
Thank you
Go to Top of Page
   

- Advertisement -