SSIS Violation of UNIQUE KEY
i am trying to insert a row of data using SSIS package. The destination table has a unique constraint on a pair of columns. When I run the package it errors reading: Violation of UNIQUE KEY constraint ...... This even happens when there is no data in the table. However, when I insert the row using TSQL it works. Hmmmm... can anybody help? Mr Shaw
March 31st, 2011 8:26am

but is the TSQL statement ignoring the unique constraint?Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2011 8:31am

but is the TSQL statement ignoring the unique constraint? Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com there is nothing in the table.... Mr Shaw
March 31st, 2011 8:38am

there is nothing in the table.... Mr Shaw OK, but two new records can also violate each other... Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2011 8:47am

There is no miracles, put the same insert statement into a SSIS package and see...Just did a quick test and it worked as expected CREATE TABLE t2(c1 INT, c2 INT) ALTER TABLE t2 ADD CONSTRAINT _uniq UNIQUE (c1,c2) INSERT INTO t2 VALUES (1,1)---ok INSERT INTO t2 VALUES (1,1)---failed INSERT INTO t2 VALUES (NULL,1)---ok INSERT INTO t2 VALUES (1,NULL)---ok INSERT INTO t2 VALUES (NULL,1)---failedBest Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
March 31st, 2011 8:53am

there is nothing in the table.... Mr Shaw OK, but two new records can also violate each other... Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com I am inserting One record into an empty table and I am getting the error. If I script the insert outside of SSIS it works. Mr Shaw
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2011 8:56am

How are you inserting that one record in SSIS?MCTS, MCITP - Please mark posts as answered where appropriate.
March 31st, 2011 9:28am

My mistake.. It looks like I was truncating the wrong table before doing the inserts.... Thank you for help.Mr Shaw
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2011 9:35am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics