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

Stored Procedure...??? 1

Status
Not open for further replies.

zandyke

Programmer
Sep 11, 2006
2
0
0
MY
I am making an online booking site, and using ASP and SQL server 2k5, now how can I allow an individual to make only three bookings (per user)and thats it???
even if he tries in a few days it wont allow him or her, im thinking mayb i have to tell sql to allow three user IDs for a field or what ....HELP
happy.gif
 
If you're writing an SP on this, I'm thinking the best way to do it is use GROUP BY UserID HAVING COUNT(UserID) <= 3 if you want to allow the booking or use a HAVING COUNT(UserID) > 3 for your denial.

Lookup GROUP BY and HAVING in Books Online for more details.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
Hi all,

Would it not be better to use a constraint on the table (on userid fields) for integrity, as it seems there is a need to stop bookings in the future. Rather than rely on the code in the SP, would a constraint not be more solid?

Rgds,

M.
 
Wow. Someone's actually trying to make sense on this forum? @=)

You know, some of us actually like doing things the hard way... (not!). @=)

Good point, actually. I should have thought of that myself. Star for you.



Catadmin - MCDBA, MCSA
"No, no. Yes. No, I tried that. Yes, both ways. No, I don't know. No again. Are there any more questions?"
-- Xena, "Been There, Done That"
 
Thanks Cat,

It was a "looking forward to the weekend" brain-burp. Couldn't come up with the code in the mood I'm in but occasionally I have a good idea! Sometimes I think logically, sometimes I do what you said and do the hard way.....It's always a week after you've got it working that Homer pops into the brain and you say "D'oh.....why didn't I......??"

If any programmers do come up with code it would be most helpful!

Cheers,

M.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top