I have a situation where I need to enforce a unique constraint on a set of columns, but only on a single column value.
So, for example, I have a table like Table (ID, Name, RecordStatus).
RecordStatus can only have a value of 1 or 2 (active or remote), and I want to create a unique restriction on (ID, RecordStatus) only in RecordStatus = 1, since I don't care if there are several deleted records with the same identifier.
Besides writing triggers, can I do this?
I am using SQL Server 2005.
sql sql-server sql-server-2005
np-hard May 14 '09 at 21:57 2009-05-14 21:57
source share