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 2005 Forums
 Transact-SQL (2005)
 Case Statement...error

Author  Topic 

dnf999
Constraint Violating Yak Guru

253 Posts

Posted - 2007-03-21 : 08:38:24
Please help:

select
case when (PROJ_LOC_1 = 'N/A' then '' else PROJ_LOC_1) as PROJ_LOC_1
from Table

Error:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'then'.

I just want to PROJ_LOC_1 to display blank if equal to N/A

Thanks!

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-03-21 : 08:39:39
remove the parens, add "end" :

case when PROJ_LOC_1 = 'N/A' then '' else PROJ_LOC_1 end as PROJ_LOC_1

When in doubt, check the syntax in Books On Line. (the SQL Server help files)

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -