SQL 如何更新具有“空白”值的列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5999884/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 10:32:55  来源:igfitidea点击:

How to update a column with a "blank" value

sqlsql-update

提问by Avinash

How do I update a column value (varchar(20), not null) with a "blank" value?

如何varchar(20), not null使用“空白”值更新列值 ( )?

回答by Louis

If you want to update it with NULLyou will need to change it to allow NULL. Otherwise update with an empty string "".

如果要更新它,NULL则需要将其更改为 allow NULL。否则用空字符串更新""

回答by Nanda

Update TableName Set ColumnName='' where [Condtion] // To update column with an enpty values

回答by Mitul Panchal

If there have any int column which you may want to do null

如果有任何 int 列您可能想要做 null

Update TABLE_NAME set name = '',id = cast(NULLIF(id,'') as NVARCHAR)

Update TABLE_NAME set name = '',id = cast(NULLIF(id,'') as NVARCHAR)