开发者

How do I check if a SQL Server datetime column is empty?

开发者 https://www.devze.com 2023-02-01 17:49 出处:网络
How do I chec开发者_JS百科k if a SQL Server datetime column is empty?Test it with IS NULL. If using .NET, test against DBNULL.... WHERE [ColumnName] IS NULL

How do I chec开发者_JS百科k if a SQL Server datetime column is empty?


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?


To get all rows wtih an empty datetime column you could do this:

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 Use IsDBNull or in transact sql use is null.


Just as an alternative to using NULL, you could try:

SELECT * FROM table_name WHERE column_name = '0000-00-00'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号