Reputation: 12729
How can I make an int column unique - on an existing table with data in - but allow multiple nulls - in SSMS.
There are many records in the table now - and they all have NULL in this column now.
I have seen ways to do this using a unique filtered index in TSQL - and I can see ways in the UI to do it without allowing NULLS.
Is this just not possible using the SSMS GUI?
As an aside what's the best way to do this just using pure TSQL? A unique filtered index?
Upvotes: 1
Views: 84
Reputation: 38023
With code:
create unique nonclustered index uixf_mycol
on dbo.t (col)
where col is not null;
In SSMS:
filter
panel.Upvotes: 2
Reputation: 28741
You can create UNIQUE
constraint on the column.
CREATE TABLE Test
(
P_Id int,
CONSTRAINT uc_ID UNIQUE (P_Id)
)
Upvotes: 0