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
 General SQL Server Forums
 New to SQL Server Programming
 Easy case question, non boolean type error

Author  Topic 

fuzzyip
Starting Member

35 Posts

Posted - 2008-08-06 : 16:32:49
select

carcat = CASE WHEN name LIKE '%Acura%' and '%CL%' then 'Coupe'
WHEN name LIKE '%Acura%' and '%Integra 2dr%' then 'Coupe'
WHEN name LIKE '%Acura%' and '%Integra 4dr%' then 'Sedan'
else unknown end



is coming up with the following error

Msg 4145, Level 15, State 1, Line 3
An expression of non-boolean type specified in a context where a condition is expected, near 'then'.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-06 : 16:36:22
This should get you going:
WHEN name LIKE '%Acura%' and name LIKE '%CL%' THEN 'Coupe'
...
ELSE 'unknown'
END

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2008-08-06 : 17:00:35
Couldn't you also do this:

WHEN name LIKE '%Acura%CL%' THEN 'Coupe'

Of course if the 'CL' came before 'Acura' then it wouldn't work.
Go to Top of Page
   

- Advertisement -