I have a SQL table with a column called [applied], only one row from all rows can be applied ( have the value of 1) all other rows should have the value 0
Is there a check constraint that i can write to force such a case?
Advertisement
Answer
Most databases support filtered indexes:
create unique index unq_t_applied on t(applied) where applied = 1;