Thursday, December 13, 2012

SQL: Setting Value to Column with NULL values

Here is the structure of how to update a table column which has NULL values in it.

UPDATE TableName SET ColumnName = NewValue where ColumnName Is Null

Now lets apply it against a real scenario.

update Student set IsAdded = 0 where IsAdded Is Null

After executing this query all the values for the column IsAdded gets to 0 where it has NULL values.

Hope you have got the idea.


No comments:

Post a Comment