Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

null column concatenation

Status
Not open for further replies.

tran008

Technical User
May 14, 2003
110
US

If col1 is null...
this statement doesn;t seem to work.
update table set col1=col1 +'-VAR' where id=idNumber. Alway return Null value.

this will work
update table set col1=isnull(col1,'')+'-VAR' where id=idNumber

Can anyone explain this? I'm using sql 2000.
 
col1 must have null values in it. Nulls propagate. They represent the value "don't know the value." So what do you have when you add "dont' know the value" to a value? You get "don't know the value" again.

[COLOR=#aa88aa black]Cum catapultae proscriptae erunt tum soli proscript catapultas habebunt.[/color]
 
Ah, nulls.

NULL is not equal to anything, even other NULLs. Any comparision with NULL always results in an unknown value.

BTW - COALESCE and CASE are preferred over ISNULL.

< M!ke >
I am not a hamster and life is not a wheel.
 
>>Any comparision with NULL always results in an unknown value

depending on the ANSI_NULLS setting of course (which by default is on)

Code:
if null = null
print 'yes'
else 
print 'no'



set ansi_nulls off
go

if null = null
print 'yes'
else 
print 'no'

Denis The SQL Menace
--------------------
SQL Server Code,Tips and Tricks, Performance Tuning
SQLBlog.com, Google Interview Questions
 
thanks everyone...Good edumaction about SQL NULL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top