Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Setting primary key

Author  Topic 

sqlsucks
Starting Member

2 Posts

Posted - 2007-01-10 : 15:02:19
I have a table, let say it is called 'profile', already created without a primary key. Now, I want to add a primary key to one of the fields called serialno on that table. I am currently using EMS SQL Manager 2005 tool to manage my db and tables. When I try to add the primary key, I am getting following error message.
"CREATE UNIQUE INDEX terminated because a duplicate key was found for index ID 1. Most significant primary key is ''"

I need help!! Otherwise, I have to create a whole new table and I can't afford do that.

Thank You.

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-01-10 : 15:41:13
The error message is telling you the problem: it cannot create the primary key because you do not have unique data in that column. You must ensure that the data in your column is unique before SQL Server can enforce a primary key on it. Makes sense ?

- Jeff
Go to Top of Page

sqlsucks
Starting Member

2 Posts

Posted - 2007-01-10 : 16:53:29
Thanks. I did not realize they use 'a duplicate key' instead of something like 'duplicate data'.
Go to Top of Page
   

- Advertisement -