Violation of primary key
Hi,
I am trying to load a table.
I get the ollwoing error as
"Violation of PRIMARY KEY constraint 'Sec_Group_pk'. Cannot insert duplicate key in object 'Sec_Group'."
Can anyone help on this...
November 23rd, 2010 1:54am
Error is Clear.
seems that you try to insert DUPLLICATE value in a Primary key,
you can configure error output as IGNORE to ignore duplicate values.http://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 1:56am
Is this the only solution.
Coz if i do so this i might not get any data for that column
November 23rd, 2010 2:49am
I am still getting the error even after applying Ignore Failure..:(
Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 2:52am
let us know why you want to import duplicate data? what is your scenario exactly?
do you want to implement UPSERT ( update if data exists in destination/ insert if data not exists in destination) ?
http://www.rad.pasfu.com
November 23rd, 2010 3:03am
Is the table empty before inserting the data?
If so, than the double keys are already in your Source.
Redirect the Error output to another table oder flatfile to check, where the problem is.
If not, put a lookup to your destination table before the OLEDB-Destination and direct only the missing data to it.
Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 3:08am
No i dont want to insert duplicate records.
I jus want to clear this error...which i couldnt do by ignore..
Help me pls
November 23rd, 2010 3:10am
give us screenshot of how you configured error output?http://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 3:12am
I configured it on OLEDB Destination
--Sorry not able to send the screen shot..it is taking time
November 23rd, 2010 3:22am
The table has data before inserting the records.
I actually tried to delete the records and load in that case there was no problem. But in few tables im not even able to delete the records, when i try to delete i get the message as
"DELETE statement conflicted with COLUMN REFERENCE constraint 'Sec_EmployeeGroup_fk1'. The conflict occurred in database 'DEV', table 'Sec_EmployeeGroup', column 'Employee_ID'."
Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 3:26am
This is, why there is a FK on the table.
Try the way with the Lookup Task I write earlier.
To Ignore the error will not solve your problem. Better way is the Lookup Task or direct the Error Output to another table.
November 23rd, 2010 3:46am
Hey Christa,
Can you give me a detail expalination on using lookup task for this scenario.
Im new to this It would be a great help.
Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 3:53am
You put a Lookup Task between Source and destination what looks on your destination table. Then take the output "no match found" (2008) or the red line (2005) and direct this to your Destination.
This will only direct the missing rows.
Another way:
Import the data into a staging table (same schema as the Destination but without PK). Then you can do all your inserts and updates on the SQL Server using the Merge-Statemant (2008) or update and insert (2005).
November 23rd, 2010 4:08am
In the lookup task i need to connect to the destination DB an table right?
Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 4:57am
Yes. you need to configure the destination DB table in lookup and match the primary key field on both your source and destination in lookup.
November 23rd, 2010 6:22am