SQL replace all NULLs

后端 未结 9 577
醉酒成梦
醉酒成梦 2020-12-09 11:34

I have a big table with some NULLs in it. What is the easiest possible way to select from the table with 0\'s instead of NULLs.

Or if there is no easy way to do that

9条回答
  •  清歌不尽
    2020-12-09 11:48

    Alternatively to ISNULL, you can use COALESCE, which is ANSI SQL compatible.

    select coalesce(yourcolumn, 0)
    

    There is lots of columns, I don't want to have to go through each one with something like ISNULL(FieldName,0) AS FieldName.

    You can't always get what you want. Too bad. This is the way to go: column by column.

提交回复
热议问题