Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 16th, 2004, 06:25 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem searching for NULL values

Is it possible to search the rows in a table for null values? I've tried the following...

ALTER PROCEDURE GetApplicantsBetweenDates
(@StartDate smalldatetime,
@EndDate smalldatetime)
AS

SELECT ParticipantID, DateApplied, FirstName, LastName, City, Season, [Year], Speaking
FROM Participant
WHERE ProgramID = NULL AND (DateApplied BETWEEN @StartDate AND @EndDate)
ORDER BY DateApplied DESC

...and it returns no data (even though there are rows in the Participant table with ProgramID = NULL and within the date range).

I've tried changing the WHERE line to WHERE ProgramID = 5 AND (DateApplied BETWEEN @StartDate AND @EndDate) and it returns all the rows with program ID = 5 and within the specified date range.

Any ideas about what the problem is? Your help is greatly appreciated.

Dan
  #2 (permalink)  
Old June 16th, 2004, 06:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Change it to

Code:
ALTER PROCEDURE GetApplicantsBetweenDates
(@StartDate smalldatetime,
@EndDate smalldatetime)
AS

SELECT ParticipantID, DateApplied, FirstName, LastName, City, Season, [Year], Speaking
FROM Participant
WHERE ProgramID IS NULL AND (DateApplied BETWEEN @StartDate AND @EndDate)
ORDER BY DateApplied DESC
Cheers!

_________________________
-Vijay G
Strive for Perfection
  #3 (permalink)  
Old June 16th, 2004, 06:52 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Worked like a charm. Many, many thanks for the quick reply Vijay.


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to handle null values imaginevictor ASP.NET 1.x and 2.0 Application Design 1 March 20th, 2007 01:52 AM
Null values jmcgranahan BOOK: Access 2003 VBA Programmer's Reference 0 August 29th, 2006 02:25 PM
Outputing Null values. Neal XSLT 2 July 25th, 2006 05:46 AM
searching a table for values Nayt32 Access VBA 4 February 27th, 2006 11:19 AM
Searching and Checking Values in other workbooks lavaguava13 Excel VBA 1 September 17th, 2005 04:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.