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)
 If the field is null, update

Author  Topic 

Zath
Constraint Violating Yak Guru

298 Posts

Posted - 2007-09-11 : 11:42:34
I have an update clause:

Update myTable
Set fld1 = @param1, fld2 = @param2


Now, I remember some time back but can't find, that if the field is null, update it.

So, if fld2 IsNull, update it with param2, otherwise, skip it.


Thanks,

Zath

X002548
Not Just a Number

15586 Posts

Posted - 2007-09-11 : 11:59:29
fld2 = COALESCE(fld2,@param2)



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -