简体   繁体   中英

How To Remove Null Values in SQL from Multiple columns?

I have enormous amount of null values accross my SQL tables and it takes forever to remove them Column by Column. Is there a shortcut to replace all Null values with "N/A" Text.

    Column1 Column2 Column3 Column4
row 1   David   **Null**    15th Dec    $5666
row 2   **Null**    Director    10th JAN    $9500
row 3   John    Janator **Null**    $1000
row 4   Steve   Market  6th FEB **Null**

Maybe this way:

update tab
set Column1 = coalesce(Column1,'N/A'),
    Column2 = coalesce(Column2,'N/A'),  
    Column3 = coalesce(Column3,'N/A'), 
    Column4 = coalesce(Column4,'N/A')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM