Archive for July 19th, 2013
10 things in SQL Server (which don’t work as expected)
Comments enabled. I *really* need your comment
10. Unique NULL
![Snowflake_300um_LTSEM[1]](https://explainextended.com/wp-content/uploads/2013/07/Snowflake_300um_LTSEM1-e1374253595235.jpg)
When declaring UNIQUE constraints on columns, SQL Server treats all NULL values as unique. This means you can't have more than one NULL value in a unique column.
This behavior violates the standard and is specific to SQL Server.
To work around this, implement the constraint by declaring a UNIQUE index which would exclude NULL values:
Subscribe in a reader