Unique Constraint for Bit Column Allowing Only 1 True (1) Value Unique Constraint for Bit Column Allowing Only 1 True (1) Value sql-server sql-server

Unique Constraint for Bit Column Allowing Only 1 True (1) Value


Just one active record at a time in the table? You can use a unique index with a filter:

create unique nonclustered index uixf_tblExample_Active_filtered  on tblExample (Active)    include (ExampleId, WordsAndStuff) -- optional included columns  where Active=1