Although I'd prefer to avoid one, it appears a trigger is the only way to accomplish what I need.
Below is my first attempt at writing a trigger. It prevents the total RSVPs for an activity (RsvpGuests) from exceeding the value in a column in the Activity table (ActCapacity).
It appears to work. Any suggestions? In particular, any way to make it more efficient?
ALTER TRIGGER dbo.LimitRsvps
FOR INSERT, UPDATE
-- Nothing to do if no rows have changed
IF @@ROWCOUNT = 0
SET NOCOUNT ON;
DECLARE @ActivityID int;
DECLARE @Capacity int;
DECLARE @Rsvps int;
View Complete Post