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
 Append to a null column

Author  Topic 

calvinfoo
Posting Yak Master

129 Posts

Posted - 2010-11-17 : 23:15:16
[code]UPDATE PR_headers SET remark = remark + 'new text' WHERE ID = 123[/code]

It doesn't work if the remark is null, please advise

p/s:
SQL Server 2005
remark is nvarchar(Max)

chadmat
The Chadinator

1974 Posts

Posted - 2010-11-18 : 00:27:11
UPDATE PR_headers SET remark = isnull(remark,'') + 'new text' WHERE ID = 123

-Chad

Go to Top of Page

calvinfoo
Posting Yak Master

129 Posts

Posted - 2010-11-18 : 00:30:42
quote:
Originally posted by chadmat

UPDATE PR_headers SET remark = isnull(remark,'') + 'new text' WHERE ID = 123

-Chad



Thanks. Managed to find out the solution and the answer is same as your suggestion.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-11-18 : 07:11:01
Reason is NULL is not regarded as a value under default conditions. So concatenation with NULL yields only NULL

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

Go to Top of Page
   

- Advertisement -