sql - select multiple columns which are null for a row -
i have 1 id column , 3 int columns. info inserted in way
insert table (col1, col2) values (1,1) insert table (col2, col3) values (1,1) insert table (col1, col3) values (1,1) insert table (col1) values (1) then, row 1, col 3 null row 2, col 1 null, row 3, col 2 null. row 4, col 2 , col 3 null.
i want replace null values 0. how can that?
note: won't know columns null, can't utilize isnull(colname, 0)
if want update table nulls become 0, utilize coalesce():
update table t set col1 = coalesce(col1, 0), col2 = coalesce(col2, 0), col3 = coalesce(col3, 0) col1 null or col2 null or col3 null; coalesce() ansi-standard function replacing null value else.
sql sql-server
No comments:
Post a Comment