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)
 Correct CASE syntax

Author  Topic 

cronincoder
Yak Posting Veteran

56 Posts

Posted - 2006-03-29 : 15:22:39
I've searched CASE and read some on it, but am still having problems with syntax and exactly what is allowed in a CASE statement. I am getting errors when I try the code below. Can anyone let me know what I am doing wrong here? I'm sure something in this code is not allowed.


SELECT
CASE
WHEN T_PROPS.BPMLS = 1 THEN T_OFFICE.OFFICE_NEW_ID AS officeCode
WHEN T_PROPS.BPMLS = 0 THEN T_OFFICE.OFFICE_OLD_ID AS officeCode
END,

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-03-29 : 15:33:22
[code]
SELECT
CASE
WHEN T_PROPS.BPMLS = 1 THEN T_OFFICE.OFFICE_NEW_ID
WHEN T_PROPS.BPMLS = 0 THEN T_OFFICE.OFFICE_OLD_ID
END AS officeCode,
[/code]

Be One with the Optimizer
TG
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-03-29 : 15:34:00
If this is not the full SQL u test, post the complete query

If this is the full SQL u test
-- no comma in after END (unless there are more fields in Select List)
-- u have to add the "From <tblName>" part

Check the Books On Line (the explanation in that is quite comprehensive)

Srinika
Go to Top of Page
   

- Advertisement -