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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter null value

Status
Not open for further replies.

ShortyA

MIS
Feb 20, 2002
363
CH
Hi
I have a table with one field caled Tax (char 6). The values can be either NULL or LONDON

There is a stored procedure that uses a parameter called "@Tax".

I want to do a selection whereby if the param is set to NULL it will only return values where the Tax field is NULL. When the param is set as "LONDON" I want only those values returned where the Tax field is "LONDON". Is this possible as when I use the syntax below I get all records.

((MyTable.Tax= @Tax) OR MyTable.Tax is null)

Many thanks - ShortyA
 
(@Tax is null and MyTable.Tax is null) or
(@Tax is not null and MyTable.Tax=@Tax)
 
Fantastic! Thanks for prompt reply and sorting this out.

ShortyA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top