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 Statements

Author  Topic 

Looper
Yak Posting Veteran

68 Posts

Posted - 2010-04-23 : 09:49:58
I am trying to use the following query but I get the following error when running "System.Data.SqlClient.SqlException: None of the result expressions in a CASE specification can be NULL"

StatusId is an FK,int field that allows nulls.

CASE [StatusId]
WHEN 0 THEN NULL
END

I am using this query in a Insert Into.... Select From query - the above is in the Select part.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-23 : 09:51:48
no need of case. just use NULLIF([StatusId],0)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Looper
Yak Posting Veteran

68 Posts

Posted - 2010-04-23 : 09:55:50
Of course

thanks.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-23 : 09:56:35
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -