Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Grounds for a trigger?

Author  Topic 

SamC
White Water Yakist

3467 Posts

Posted - 2004-12-26 : 18:07:03
I just had to remove a UNIQUE constraint

CONSTRAINT [Whatever] UNIQUE (MainID, Choice)

Once upon a time, Choice (1, 2, 3, ... N) was unique, but we've added a Choice zero, and there can be any number of zeros.

Is there any way to police the UNIQUE requirement for values of Choice greater than zero without resorting to a trigger?

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-12-26 : 18:49:00
Technically my answer is no.

Would it be sound to add another table to the schema where the "zero" choices are stored ?
choice(mainid, choice check(choice>0), unique(mainid,choice))
choicezero(mainid, choice check(choice=0), choicedata, unique(mainid,choicedata))

rockmoose
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-12-27 : 02:24:09
Do all your updates go through an SProc? If so would putting the Unique test there be robust enough?

Kristen
Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2004-12-27 : 11:03:27
I think I'll use Kristen's suggestion, however, it's not quite as confidence inspiring as trusting a constraint.

I've managed so far to get away without triggers. Hate to start now.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-12-28 : 01:33:26
"I've managed so far to get away without triggers. Hate to start now."

Would you like to have an Update Date on every table / row?

An Archive repository, for some of your tables?

Embrace those triggers!

Kristen
Go to Top of Page
   

- Advertisement -