I have an accountBranchMap table which has three columns:
AccountId, BranchId, IsActive.
There is an unique index on AccountId to ensure that each account can only map to one branch.
Is there a way the unique index will only be checked on the records with IsActive = 1 ? e.g If there a row of (AccountId = 1, BranchId = 1, IsActive = 0 ), I can still insert (1, 2, 1) into the table. There can exist multiple duplicated AccountId as long as its IsActive value is false.
I am using SQL-Server 2008R2 SP1
Thank you.