Reputation: 251
How do I check if a SQL Server datetime column is empty?
Upvotes: 25
Views: 102146
Reputation: 1103
Just as an alternative to using NULL, you could try:
SELECT * FROM table_name WHERE column_name = '0000-00-00'
Upvotes: 0
Reputation: 1067
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);
Upvotes: 2
Reputation: 218808
... 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?
Upvotes: 15
Reputation: 120917
To get all rows wtih an empty datetime column you could do this:
SELECT * FROM yourtable WHERE yourdatecolumn IS NULL
Upvotes: 6