Skip to content

Instantly share code, notes, and snippets.

@blanchak
Created November 2, 2011 14:05
Show Gist options
  • Save blanchak/1333715 to your computer and use it in GitHub Desktop.
Save blanchak/1333715 to your computer and use it in GitHub Desktop.
Creating a unique constraint on a nullable column. We need to filter out the nulls. [SQL 2008]
CREATE UNIQUE NONCLUSTERED INDEX [IX_MyTable] ON [dbo].[MyTable]
(
[UniqueNullableColumn] ASC
)
WHERE ([UniqueNullableColumn] IS NOT NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment