Ah, misread the question. You can't put a unique constraint on orderid if it has multiple nulls. You either have to update them to be unique, delete them from the table, or create a unique filtered index:CREATE UNIQUE INDEX ix_UNQ_orderID ON myTable(orderid) WHERE orderid IS NOT NULL
This will work on SQL Server 2008 or higher.