SQL replace all NULLs

后端 未结 9 580
醉酒成梦
醉酒成梦 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:46

    Be a boss. Write something like:

    select 'update ' + table_name + ' set [' + column_name + '] = '''' where [' + column_name + '] is null'
    from tempdb.information_schema.columns
    where table_name = 'YourTableName'
    

    It'll spit out a big ol' query for you.

提交回复
热议问题