Check the data and your code again. If you're getting a primary key violation, especially while doing identity insert, you're attempting to add a value that already exists.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning