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.
    
        
            
                
                    
                        
                            
                                | Author | 
                                
                                 Topic  | 
                             
                            
                                    | 
                                         npgawade 
                                        Starting Member 
                                         
                                        
                                        2 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2012-07-15 : 20:08:09
                                            
  | 
                                             
                                            
                                            | Hi,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 NULLBefore 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_datesI am getting error on 1 sql.Error :Msg 1505, Level 16, State 1, Line 1CREATE 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 1Could 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.Thanks. | 
                                             
                                         
                                     | 
                             
       
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |