SQL Server Unique Index with Multiple NULL Values

Sometimes I require unique values in a column that allows nulls.

CREATE UNIQUE NONCLUSTERED INDEX IndexName ON dbo.TableName(ColumnName) WHERE ColumnName IS NOT NULL

http://connect.microsoft.com


Update: SQL Server Management Studio has this functionality built into the Index Properties dialog.

([ColumnName] IS NOT NULL)

http://stackoverflow.com