How do I change all empty strings to NULL in a table?

前端 未结 7 1429
悲哀的现实
悲哀的现实 2020-12-08 20:25

I have a legacy table with about 100 columns (90% nullable). In those 90 columns I want to remove all empty strings and set them to null. I know I can:

updat         


        
7条回答
  •  有刺的猬
    2020-12-08 20:57

    I think you'll need to pull each row into a language like C#, php, etc.

    Something like:

    rows = get-data()
    foreach row in rows
        foreach col in row.cols
            if col == ''
                col = null
            end if
        next
    next
    save-data()
    

提交回复
热议问题