Update 语句中 int 的 NULL 值 [英] NULL value for int in Update statement
本文介绍了Update 语句中 int 的 NULL 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在更新语句中为 int 列设置 NULL 值?
Is it possible to set NULL value for int column in update statement?
在这种情况下如何编写更新语句?
How can I write the update statement in this case?
推荐答案
假设列设置为支持 NULL 作为值:
Assuming the column is set to support NULL as a value:
UPDATE YOUR_TABLE
SET column = NULL
注意数据库 NULL 处理 - 默认情况下,在 SQL Server 中,NULL 是一个 INT.因此,如果该列是不同的数据类型,您需要将 NULL 转换为正确的数据类型:
Be aware of the database NULL handling - by default in SQL Server, NULL is an INT. So if the column is a different data type you need to CAST/CONVERT NULL to the proper data type:
UPDATE YOUR_TABLE
SET column = CAST(NULL AS DATETIME)
...假设 column
是上述示例中的 DATETIME 数据类型.
...assuming column
is a DATETIME data type in the example above.
这篇关于Update 语句中 int 的 NULL 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文