Deprecated: Assigning the return value of new by reference is deprecated in /f2/blendedtechnologies/public/wp-content/plugins/pmetrics.php on line 1192
Blended Technologies » Blog Archive » How to change null values into something else in MS SQL Server

How to change null values into something else in MS SQL Server

You must use:

update [table] set [field]='value you want' where isnull([field],1)=1

This page shows how to do this in all the DBs.

del.icio.us |  Digg |  FURL |  Yahoo! My Web 2.0 |  Reddit

2 Responses to “How to change null values into something else in MS SQL Server”

  1. cco Says:

    This doesn’t do exactly what you think it does. While it will set all NULL values of field to the value you want, it will also change any value of field that is = 1.

    The correct way to do this is simple:

    update [table] set [field]=’value you want’ where [field] is null

  2. Administrator Says:

    Thanks for the correction. I’ll try it out the next time I get my hands on SQL server.