By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,969 Members | 1,705 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,969 IT Pros & Developers. It's quick & easy.

SQL Server Violation of Primary Key

P: 1
I have a table, "SOME_TABLE", with a clustered primary key on a character column, "XYZ_ID". I copied this table to a temporary backup table using "select * into SOME_TABLE_BKUP from SOME_TABLE". Then I dropped and re-created the original table with the same table structure and primary key constraint. But when I try to insert data from the backup table, "insert into SOME_TABLE select * from SOME_TABLE_BKUP" I get a violation of primary key constraint error even though there are no duplicate primary key values. If I add the data without the primary key constraint then try to add the constraint I again get the error and it specifies a specific key value that it sees already exists but when I query the data for that specific key value there is only one record.
Feb 26 '14 #1
Share this Question
Share on Google+
1 Reply


P: 16
is your Primary Key has an identity value in SOME_table? if yes, try to insert the data except the primary key, so that your table automatically gives the value to primary key column.
Feb 26 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.