Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I edit my database to not allow duplicate values in a field

Status
Not open for further replies.

Dauz

MIS
Apr 21, 2003
4
US
Here's my problem:

There's a field in my database called ESN that currently allows duplicate values. The values are stored as either 8 digit hex values (e.g. 8AFC11FF) or as 11 digit decimal values (12212344311). We now are not allowing any new and existing values in this field to be duplicate.

HOW WOULD I DO THIS?

I'm sort of new to SQL Server. Any help would be great!

Thanks in advance
 
If your table already exists duplicate key,first you need to delete all the duplicate rows.
After deleting all the duplicate rows.Add primary key on that column where you dont want any duplicate value occurs again.

alter table table_name add constraint PK_name
primary key clustered (column name)
 
Thanks, I did that and it works great. BUT! I was wondering now how I could notify the user of a duplicate value via the .asp webpage their entering the data from.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top