The proper way to implement unique constraint that allows multiple NULL values in SQL Server

前端 未结 3 1913
臣服心动
臣服心动 2020-12-17 19:52


I need 1 column in the table to hold unique non-null values or NULL. TSQL UNIQUE constraint treats 2 NULLs as equal, so I cannot

3条回答
  •  伪装坚强ぢ
    2020-12-17 20:33

    Normalise it. Move the column to a new table together with your current table's primary key. Make the column unique and not null in the new table. Nullable unique constraints make no logical sense and are of little or no practical use.

提交回复
热议问题