February 26, 2008 at 5:51 am
SELECT CASE WHEN CurrentSickTerm= 'LT'THEN 'Long Term' ELSE if CurrentSickTerm= 'ST'THEN 'Short Term' else 'NULL' END AS ColumnNameFROM dbo.ViewName
This does not work I need another way to write this
February 26, 2008 at 5:56 am
Your syntax is wrong from BOL:-
SELECT au_fname, au_lname,
CASE state
WHEN 'CA' THEN 'California'
WHEN 'KS' THEN 'Kansas'
WHEN 'TN' THEN 'Tennessee'
WHEN 'OR' THEN 'Oregon'
WHEN 'MI' THEN 'Michigan'
WHEN 'IN' THEN 'Indiana'
WHEN 'MD' THEN 'Maryland'
WHEN 'UT' THEN 'Utah'
END AS StateName
FROM pubs.dbo.authors
ORDER BY au_lname
February 26, 2008 at 6:09 am
Help - it does not work within a view as it does not accept case statements
March 7, 2008 at 12:00 pm
View definitions support Case functions just fine.
The query designer may not, but then just don't use the query designer. (I would never use it anyway).
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply