SQL Unique Index that Allows NULLS


Example

CREATE UNIQUE INDEX idx_license_id 
   ON Person(DrivingLicenseID) WHERE DrivingLicenseID IS NOT NULL
GO

This schema allows for a 0..1 relationship - people can have zero or one driving licenses and each license can only belong to one person