Options, in order of preference:
SCHEMABINDING and a unique clustered index over an inner join of the two tables. SQL Server enforces it on every write in the same transaction. Limits: inner joins only, deterministic expressions, required SET options, and extra write cost and lock contention on hot keys.inserted against the other table and rolls back. Flexible, but hidden logic, extra latency on every statement, and it must use locking hints (UPDLOCK, HOLDLOCK) to be race-safe.UPDLOCK, HOLDLOCK (or serializable). Works only if every writer goes through it and reduces concurrency on the checked range.Prefer the indexed view for pure uniqueness; measure insert latency before and after.
Checks knowledge of indexed views, triggers and their trade-offs.
Last updated 23 Nov 2026.