Posted - 07/15/2012 : 20:12:25
I am trying to add PK on exsting table having data.
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.
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.