Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Re: Select CASE...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 11004 of 11517
Post > Topic >>

Re: Select CASE returning NULL value

by "Plamen Ratchev" <Plamen@[EMAIL PROTECTED] > Apr 26, 2008 at 01:44 PM

You cannot check NULL for equality (it is unknown, so it doesn't equal 
another unknown). The correct way to check if expression is NULL is using
IS 
NULL:

CASE WHEN [dbo].[tblContact].[JobTitleID] IS NULL THEN ...

The code that you posted can be simplified using the COALESCE function:

[dbo].[f_ContactNameFL]([dbo].[tblContact].[ContactID]) +
COALESCE(', ' + [dbo].[tlkpJobTitle].[Title], '') AS ContactNameAndTitle

HTH,

Plamen Ratchev
http://www.SQLStudio.com
 




 2 Posts in Topic:
Select CASE returning NULL value
"sbowman@[EMAIL PROT  2008-04-26 08:34:44 
Re: Select CASE returning NULL value
"Plamen Ratchev"  2008-04-26 13:44:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 1:16:37 CST 2008.