(This is a follow up to an issue I posted about previously.)
I have a table of Activities, Users, and RSVPs, where RSVPs signify a user's intention of attending a particular activity, along with any number of guests.
In some cases, there will be a limit to the number of RSVPs (including guests) allowed for a particular activity. So I need to limit SUM(RsvpGuests) to this value.
I've come up with the following stored procedure but SQL isn't my specialty and I'm looking for some constructive criticism. One weakness I can see is that this procedure will fail to add the RSVP if another thread exceeds the limit at around the same time.
But I don't really see anything better. A trigger was suggested but that may be beyond my abilities (and I wasn't able to get answers to some of my questions about triggers).
ALTER PROCEDURE dbo.tc_RsvpsUpdate
@ExceededBy int OUTPUT
View Complete Post