by Scott
1. April 2010 19:06
I have an integer column in one of my database tables that allows nulls. What I want is for any value other than nulls to be unique. Here's how I did it:
CREATE UNIQUE NONCLUSTERED INDEX idx_SupplierID_notnull
ON Brands(SupplierID)
WHERE SupplierID IS NOT NULL;
Brands is my table and SupplierID is the column I want to be unique.