SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 1 SP for different selections
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

richardlaw
Yak Posting Veteran

United Kingdom
66 Posts

Posted - 08/01/2012 :  17:18:58  Show Profile  Visit richardlaw's Homepage  Reply with Quote
Hi

I've created a table that lists members of a gymnastics club. In the table is a bool/bit value for isGymnast and isCoach, as many of our coaches are also gymnasts.

I've like to create one SP to manage 3 selection types. Just gymnasts, just coaches, and everyone, but I'm not quite sure how to write it or what method to use?

When selecting just the gymnasts, I can't use 'isGymnast = 1 AND isCoach = 0' as this would discount gymnasts that are also coaches.

Any ideas?

Thanks as always

visakh16
Very Important crosS Applying yaK Herder

India
48012 Posts

Posted - 08/01/2012 :  17:32:31  Show Profile  Reply with Quote
you can use like this
add a mode parameter @Mode and pass values like Gymnast,Coach

and make filter like

..
WHERE (@Mode!='Gymnast' OR isGymnast=1)
AND (@Mode !='coach' OR isCoach=1)



see

http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

richardlaw
Yak Posting Veteran

United Kingdom
66 Posts

Posted - 08/01/2012 :  17:37:11  Show Profile  Visit richardlaw's Homepage  Reply with Quote
Great, thanks. I'll try that out.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000