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
 update Nulls

Author  Topic 

joelseverich
Starting Member

34 Posts

Posted - 2009-02-12 : 16:34:59
hi there
is there a way to update all Null values with A Different value
ex. I have a Column (Bit) and i want to set all null values to false
I tried to do this

UPDATE Table SET Col=0 WHERE Col=NULL

but it doesn't work , would please help me

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-12 : 16:35:28
UPDATE Table SET Col=0 WHERE Col is NULL
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-12 : 16:37:06
[code]UPDATE Table SET Col = Coalesce(Col,0)[/code]
Go to Top of Page

joelseverich
Starting Member

34 Posts

Posted - 2009-02-12 : 16:39:21
thanks a lot
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 20:28:31
quote:
Originally posted by joelseverich

thanks a lot


the reason why your query not worked is because NULL is not stored as a value. so operators like =,>,<,...wont work with NULL under default settings. if you want NULL to be considered as value, you need to alter ANSI NULL settings
Go to Top of Page
   

- Advertisement -