473,378 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

SQL Server Violation of Primary Key

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
1 1435
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

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

Similar topics

3
by: DaveR | last post by:
When I export a table from my local SQL Server to my web-host's SQL Server, the primary key never seems to export. This happens whether I use the "Copy tables and views..." option or the "Copy...
4
by: serge | last post by:
I ran into a table that is used a lot. Well less than 100,000 records. Maybe not a lot of records but i believe this table is used often. The table has 26 fields, 9 indexes but no Primary Key at...
0
by: Enzo Marinelli | last post by:
Hello everyone I have a HUGE database, with very complex stored procedures that handle every possible error and the passed it to an ASP site with RAISERROR Now I need to use that same database...
0
by: dhnriverside | last post by:
Hi guys Wondering if you can help me with a setup issue. All my development is web based, using IIS5.1 on a Windows 2000 Server running Active Directory. Everything was working fine until I...
1
by: Mark A | last post by:
DB2 ESE 8.2.3 (FP10) for Linux We are experiencing a connection hang of 10 - 15 minutes in the following HADR and automatic client reroute scenario: 01 server is primary database 02 server is...
2
by: John | last post by:
The ASP application inserts transaction records in transaction table with the system time as the primary key. However, it is possible to have primary key violation because the records in...
1
by: greentopper | last post by:
Hi I am a first time user of sql server, and of late I am trying to build a database using sql server and I am starting to panic. This is what I am trying to do: I am creating a db to register...
1
by: Zamdrist | last post by:
Violation of PRIMARY KEY constraint 'PK_CUSTOM2'. Cannot insert duplicate key in object 'MHGROUP.Custom2' Is there ANY other reason this violation of the primary key would happen OTHER than a...
7
by: akmaRudiliyn | last post by:
Hai everybody :). I have problem and need help. ERROR: ERROR Violation of PRIMARY KEY constraint 'PK_Table1_01'. Cannot insert duplicate key in object 'dbo.table1'. ERROR The statement has...
0
by: NewBornDBA | last post by:
I am a sql server DBA. I don't know anything about MySQL. The problem is that "/var/lib/MySQL" maxed out disk space and caused MySQL to crash. I was able to move all the files to /home and I was also...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.