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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Unable to add primary key
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 07/15/2012 :  20:12:25  Show Profile  Reply with Quote

I am trying to add PK on exsting table having data.

My script:

1.ALTER TABLE dbo.Posting_Zeroes_post_dates ADD [ID] [INT] PRIMARY KEY IDENTITY (1, 1) NOT NULL

Before running this script I am droping the exsisting index on that table . just giving more details.

2.ALTER TABLE dbo.Posting_Zeroes_post_dates DROP CONSTRAINT IX_Posting_Zeroes_post_dates

I am getting error on 1 sql.
Error :
Msg 1505, Level 16, State 1, Line 1
CREATE UNIQUE INDEX terminated because a duplicate key was found for object name 'dbo.Posting_Zeroes_post_dates' and index name 'PK__Posting_Zeroes_p__20285207'. The duplicate key value is (69).
Msg 1750, Level 16, State 0, Line 1
Could not create constraint. See previous errors.
The statement has been terminated.

I have check and could not find duplicate records.

I am restoring data from Prodcution to Test and ran the above sql , i got above error but if i ran the sql again after half an hour it ran sucessfully.

Any help would be appreciated.


Starting Member

10 Posts

Posted - 07/18/2012 :  08:59:41  Show Profile  Reply with Quote
I believe you need to include the Key Name as shown below:

ALTER TABLE dbo.Posting_Zeroes_post_dates ADD [ID] [INT] PRIMARY KEY (IX_Posting_Zeroes_post_dates) IDENTITY (1, 1) NOT NULL

Go to Top of Page

Starting Member

1 Posts

Posted - 12/18/2014 :  02:57:18  Show Profile  Reply with Quote
hi ,

i am working on my project .i just need little help from sql server.i installed it and when i start it it appears " connect to server " window. whiask for server name. Plz guys tell me whats the server name i have to enter bacause i have tried all names like pc name ,comouter name....

Plz somebody tell me the solution...

We are the pioneers in providing [url=]mcsa certification[/url] toefl and [url=]itil dumps[/url] with 100% exam pass [url=]northwood[/url] Download our latest passguide gmat and [url=][/url] ccna or pass real exam of [url=]Florida Memorial University[/url]

Edited by - zohaa3492 on 01/02/2015 06:46:47
Go to Top of Page

Aged Yak Warrior

737 Posts

Posted - 12/18/2014 :  03:11:49  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
it is the instance name that you gave when installing sql server on your machine.
click on 'Browse for more' under servers and you must see the instance name under local server-database engine

Javeed Ahmed

Edited by - ahmeds08 on 12/18/2014 03:14:45
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000