Solved

a way to filter using parameters including nul/blanket records?

Posted on 2010-09-20
4
248 Views
Last Modified: 2012-05-10
I am using a paramter to query the table. ProjectTable(id,status,team).

Select * From projectable where team in (@team)

OK this is fine but I also would to include null and blanket value when I select all teams from the parameters.

How can I do that?
0
Comment
Question by:dkim18
4 Comments
 
LVL 8

Assisted Solution

by:nognew
nognew earned 100 total points
ID: 33718297
Hi there!
 how about that:
Cheers,
t.
Select * From projectable where team in (@team) or team is null

Open in new window

0
 
LVL 11

Accepted Solution

by:
aelliso3 earned 300 total points
ID: 33718657

If you only want to include null and blank values when you select all, then there's a couple of steps to it. The suggestion above will include NULL values when any query is returned.

In your query that provides the paramater values, do a union to add in the first row like below:

SELECT id=999, Status='', team = 'SELECT ALL'
UNION
SELECT id, status, team FROM projectable

This will add one more value to your list that will bring back everything if selected. Otherwise, you'll only get what you selected without the Nulls and blanks.

Select id, active, team
From projectable
where id in (@team)
     or @team = 'SELECT ALL'
0
 
LVL 15

Assisted Solution

by:AmmarR
AmmarR earned 100 total points
ID: 33718718
Dear dkim18

check the code below,
SELECT * FROM projectable  where team in (@pteam) or (@pteam is null and team is null)

Open in new window

0
 

Author Closing Comment

by:dkim18
ID: 33833865
o
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now