I want make a update query in sql-server which can update any null value to zero in a table.
Asked
Active
Viewed 3,427 times
-2
-
7Use: `UPDATE mytable SET myfield = 0 WHERE myfield IS NULL` – Giorgos Betsos Mar 20 '18 at 07:33
-
Possible duplicate of [Altering a column: null to not null](https://stackoverflow.com/questions/689746/altering-a-column-null-to-not-null) – AbsoluteƵERØ Mar 20 '18 at 07:35
-
1Why? Null values make sense. If you don't understand them, learn how to deal with them! – jarlh Mar 20 '18 at 07:39
-
Btw, _mycolumn_, not _myfield_... – jarlh Mar 20 '18 at 07:39
-
@jarlh The reason is irrelevant, OP asked for a question and needs an answer ^^. – Yassine Badache Mar 20 '18 at 07:40
-
@YassineBadache, OP has a problem - whatever it is - and is perhaps doing something completely wrong.' – jarlh Mar 20 '18 at 07:43
-
@jarlh Yes, he has a problem. About this problem, he wants to make an update in SQL Server, which can update any `null` value to zero in a table. Could you provide OP with such an answer ? – Yassine Badache Mar 20 '18 at 08:46
-
@YassineBadache, don't be such a smarty*ss. – jarlh Mar 20 '18 at 08:53
2 Answers
1
This basic request will do it:
UPDATE <Table> SET <Column to update> = 0 WHERE <Column to update> IS NULL;
NB: Capital letters are not relevant.

Yassine Badache
- 1,810
- 1
- 19
- 38

Ganesh
- 486
- 3
- 8
- 18