如何检查SQL Server datetime列是否为空?
Test it with IS NULL
.
If using .NET, test against DBNULL
.
... WHERE [ColumnName] IS NULL
Or do you mean something else by "empty" that isn't NULL
? Does your column allow NULL
values? Are you instead looking for some kind of default value?
要使用空的日期时间列获取所有行,您可以执行以下操作:
SELECT * FROM yourtable WHERE yourdatecolumn IS NULL
This worked for me in C# , Where
con
is my Sql Connection
SqlCommand cmd = new SqlCommand("Select * From Transactions WHERE TransactionID = '"+tid+ "'AND InDate IS NULL ", con);
net使用IsDBNull或在transact sql中使用为null。
作为使用NULL的替代方法,您可以尝试:
SELECT * FROM table_name WHERE column_name = '0000-00-00'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.