How to convert empty spaces into null values, using SQL Server?

前端 未结 7 1937
無奈伤痛
無奈伤痛 2020-12-14 05:56

I have a table and the columns on this table contains empty spaces for some records. Now I need to move the data to another table and replace the empty spaces with a N

相关标签:
7条回答
  • 2020-12-14 06:35

    Did you try this?

    UPDATE table 
    SET col1 = NULL 
    WHERE col1 = ''
    

    As the commenters point out, you don't have to do ltrim() or rtrim(), and NULL columns will not match ''.

    0 讨论(0)
提交回复
热议问题