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
 case statement issue

Author  Topic 

CrazyT
Yak Posting Veteran

73 Posts

Posted - 2010-07-01 : 14:39:25
the query below works fine in my dev box -- when i move it to another sql server it errors on the case statement

any reason it would fail or is there something wrong with the statement

SELECT ID,
key =
CASE
WHEN key = 'Account' THEN '0'
WHEN key = 'BusinessAccount' THEN '1'
END,

FROM #tempTbl

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-07-01 : 15:14:44
Whats the error it returns? Did you create the temp table #tempTbl before running it?
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-07-01 : 17:05:36
There's a comma after the END before the FROM. Unless there are columns you omitted, that shouldn't be there

--
Gail Shaw
SQL Server MVP
Go to Top of Page

CrazyT
Yak Posting Veteran

73 Posts

Posted - 2010-07-01 : 17:10:28
temp table is created before running it.

I omitted the other columns.

The error it returned was a -4 i think
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-07-01 : 17:54:15
That's not a SQL error. SQL errors are all > 0 and have text messages.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-07-02 : 02:57:30
quote:
Originally posted by CrazyT

temp table is created before running it.

I omitted the other columns.

The error it returned was a -4 i think


Can you post the full code you used?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -