[MSSQL] "Where" clause on unique constraint?

Caporegime
Joined
18 Oct 2002
Posts
29,493
Location
Back in East London
Hi,

We have a table for Milestones, and of these milestones we need to constrain that for particular types of milestone, only one can exist per job.. However, for other types, many can exist.

Probably better explained in code (that doesn't work):
Code:
ALTER TABLE Milestones
  ADD CONSTRAINT Milestones_Unique UNIQUE (TypeId, JobId)
  WHERE TypeId IN (10, 11);

Can anyone offer some help? :)
 
Back
Top Bottom