10 pts.
 Recovering lost data from SQL Server 2005
Running SQL Server 2005.
I found that I had lost about 2000 records the Assets table and more records in the associated tables Timeassets and AssetBillingrates.  Each of the tables uses an Id field as the Primary Key.
I was able to identify the key records that had been lost and tried inserting them From a backup I had made back into the tables, using Set Identity_Insert to make that possible.  The attempt yields this error: Violation of PRIMARY KEY constraint 'PK_timeasset'. Cannot insert duplicate key in object 'dbo.timeasset'.  
Having made sure that the primary key records I was trying to insert into the table didn't actually exist I thought that the problem might be with the index for the PK.  After rebuilding the index and trying the insert again the result is the same.
I'd like to understand what is happening.
We ended up making a copy of the current critical files to another database, restoring a previous backup and are now inserting the then current records into the older restored backup files.
Brad Clawson


Software/Hardware used:
SQL Server 2005
ASKED: March 30, 2011  6:19 PM
UPDATED: April 2, 2011  7:08 AM

Answer Wiki:
The only reason that the error would come up would be if SQL Server already had one or more of the records there.
Last Wiki Answer Submitted:  April 2, 2011  7:08 am  by  Denny Cherry   64,520 pts.
All Answer Wiki Contributors:  Denny Cherry   64,520 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _