August 25, 2006 at 12:30 pm
Hopefully this is a very easy question.
I have a table:
PersonID int,
GroupID int,
TestFlag bit
I would like to create a constraint on this table that ensures that no more than 5 people in the same group have the TestFlag set. Is this possible?
August 25, 2006 at 2:13 pm
You could use an insert/update Trigger
August 25, 2006 at 2:25 pm
I thought about that, and I know it would work, but something in me rebels at the idea of using triggers for constraint purposes. I'd like to use a check constraint if at all possible. I tried one involving a UDF, and it worked for inserts but not updates (besides it was slow as heck).
August 25, 2006 at 2:28 pm
Sorry to kill your groove, But you either to that check before the insert in a stored proc or in a trigger. The simple constraint checks just can't handle that well...
August 25, 2006 at 3:45 pm
I finally got this to work with a constraint/UDF combo, but for some weird reason it doesn't work on Updates using Enterprise manager. With Query Analyzer the Update is constrained just like it should be. Might be a bug in EM.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy