Wednesday, March 21, 2012

Make varchar field unique

Anybody know a way to make a varchar field not allow duplicates besides
making it a primary key?hi adam,
how about creating unique constraint on the column.
Ex:
create table #t(col1 varchar(50) unique)
insert into #t values('a')
insert into #t values('b')
insert into #t values('a') -- error
-- Vishal

No comments:

Post a Comment