Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WHERE Clause concerning NULL, and datetime field

Status
Not open for further replies.

Wyldcard9

Programmer
Feb 5, 2004
82
US
The guy who designed our Microsoft SQL Server Databases, allowed datetime fields to be nulls. I ran across a record that had a null in it, and tried to create a query to determine how many records are like this.

SELECT *
FROM [elvis].[EP3_14]
WHERE ID_1015=NULL

This returns no rows at all.

I modified the code to see if I could return any rows on that datetime field, and tried this:

SELECT *
FROM [elvis].[EP3_14]
WHERE ID_1015<'2004-01-01 00:00:00.000'

This returns all records with a datetime stamp, that is below that datetime stamp. The NULL record is not displayed.

What do I need to do in order to return rows with only NULL value?

Thanks in advance.
 
SELECT *
FROM [elvis].[EP3_14]
WHERE ID_1015 IS NULL

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top