How do I set a column value to NULL in SQL Server Management Studio?

China☆狼群 提交于 2019-12-31 07:54:13

问题


How do I clear the value from a cell and make it NULL?


回答1:


I think @Zack properly answered the question but just to cover all the bases:

Update myTable set MyColumn = NULL

This would set the entire column to null as the Question Title asks.

To set a specific row on a specific column to null use:

Update myTable set MyColumn = NULL where Field = Condition.

This would set a specific cell to null as the inner question asks.




回答2:


If you've opened a table and you want to clear an existing value to NULL, click on the value, and press Ctrl+0.




回答3:


If you are using the table interface you can type in NULL (all caps)

otherwise you can run an update statement where you could:

Update table set ColumnName = NULL where [Filter for record here]



回答4:


Use This:

Update Table Set Column = CAST(NULL As Column Type) where Condition

Like This:

Update News Set Title = CAST(NULL As nvarchar(100)) Where ID = 50



回答5:


Ctrl+0 or empty the value and hit enter.



来源:https://stackoverflow.com/questions/444657/how-do-i-set-a-column-value-to-null-in-sql-server-management-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!