SQL Server 2005 – Check for Null DateTime Value

sqlsql serversql-server-2005tsql

I'm trying to count the number of records that have a null DateTime value. However, for some reason, my attempts have failed. I have tried the following two queries without any luck:

SELECT COUNT(BirthDate) 
  FROM Person p
 WHERE p.BirthDate IS NULL

and

SELECT COUNT(BirthDate)
  FROM Person p
 WHERE p.BirthDate = NULL

What am I doing wrong? I can see records with a BirthDate of NULL when I query all of the records.

Best Answer

SELECT COUNT(*)
FROM Person
WHERE BirthDate IS NULL