Friday, February 10, 2012

Converting NULL to a Text String

I'm using UPDATE as follows"

UPDATE Dubai

SET DB = 'D'

WHERE DB = NULL

but nothing happens. What am I doing wrong?

Thanks.

Your update needs to be modified from this:

Code Snippet

UPDATE Dubai

SET DB = 'D'

WHERE DB = NULL

to this:

Code Snippet

UPDATE Dubai

SET DB = 'D'

WHERE DB IS NULL

In older version of SQL Server your syntax would have worked. Null is considered a state and not a value. Null is considered a state. To check to see if a column is in a null state the syntax is to check if the column "is null".

|||

Just in addition and for reference:

http://www.sqlservercentral.com/columnists/jtravis/understandingthedifferencebetweenisnull.asp

Jens K. Suessmeyer

http://www.sqlserver2005.de

No comments:

Post a Comment