如何在 SQL Server Management Studio 中将列值设置为 NULL?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/444657/
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
How do I set a column value to NULL in SQL Server Management Studio?
提问by Zack Peterson
How do I clear the value from a cell and make it NULL?
如何清除单元格中的值并使其为 NULL?
采纳答案by Zack Peterson
If you've opened a table and you want to clear an existing value to NULL, click on the value, and press Ctrl
+0
.
如果您打开了一个表并且想要将现有值清除为 NULL,请单击该值,然后按Ctrl
+ 0
。
回答by Jeff Martin
I think @Zackproperly answered the question but just to cover all the bases:
我认为@Zack正确回答了这个问题,但只是为了涵盖所有基础:
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.
正如内部问题所要求的那样,这会将特定单元格设置为 null。
回答by TheTXI
If you are using the table interface you can type in NULL (all caps)
如果您使用的是表格界面,您可以输入 NULL(全部大写)
otherwise you can run an update statement where you could:
否则你可以运行一个更新语句,你可以:
Update table set ColumnName = NULL where [Filter for record here]
回答by Milad
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
回答by Eppz
Ctrl+0 or empty the value and hit enter.
Ctrl+0 或清空值并按 Enter。
回答by Lee Smith
CTRL+0 doesn't seem to work when connected to an Azure DB.
连接到 Azure DB 时,CTRL+0 似乎不起作用。
However, to create an empty string, you can always just hit 'anykey then delete' inside a cell.
但是,要创建一个空字符串,您始终可以在单元格内点击“anykey then delete”。