|
|
 |
RE: FN-FORUM: SQL - Only Update Column When Value Not Null
date posted 14th November 2005 10:45
[EMAIL REMOVED] wrote:
> I have a SQL stored procedure that checks the MSSQL database
> for an email address. If the email address exists then the SP
> will update any details passed to it, however I want my SP to
> only update the columns where the passed value is not null. I
> would appreciate any advice on how to achieve this as my SQL
> skills are limited mainly to simple SELECT, UPDATE & DELETE
> statements.=20
>=20
> Thanks.
check documentation for ISNULL()
[http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/tsqlr=
ef/ts
_ia-iz_6mek.asp], I think something like=20
UPDATE...SET ......,colname=3DISNULL(colname,'newval')...
should work as (iirc) ISNULL checks the first value and if it is not =
null
returns it otherwise returns the second value.
HTH,
Dai
--=20
TechnologyAngel
http://www.technologyangel.co.uk/
|
 |
|