Other Wiki Sections

Allow Duplicate Nulls in a Unique Index - SQL Server

Within a unique index in SQL Server, duplicate null values are not allowed. However, you may have a legitimate business reason for wanting to have duplicate NULL values in an index. For example, a Person table might have a SSN column that's nullable. You might have the rule that if a Social Security number is specified it must be unique. This article explains how to implement this by using a filtered unique index. (Using this technique with a unique KEY/CONSTRAINT has not been investigated, but probably is not supported.)