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
 Transact-SQL (2000)
 how to use same expression used in LIKE in WHEN

Author  Topic 

umut
Starting Member

4 Posts

Posted - 2008-12-02 : 09:38:35
Hello everyone, i would like to know how i can use same expression as i use in LIKE clause "%%" in WHEN ?

I tried below example but the %% expession does not make sense as how it does in LIKE.

CASE FIELD_NAME WHEN '%value%' THEN 10 ELSE 0 END AS SCORE

I have to catch similar words as well using CASE WHEN.

Any help will be much appreciated.

Thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-02 : 09:47:44
No, you have to specify each comparison.

CASE
WHEN FIELD_NAME LIKE '%value%' THEN 10
WHEN FIELD_NAME > 50 THEN 20
ELSE 0
END AS SCORE


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

umut
Starting Member

4 Posts

Posted - 2008-12-02 : 09:53:49
thank you very much for your response, that was the syntax i needed.
Go to Top of Page
   

- Advertisement -