dbTalk Databases Forums  

Foreign key constraint violation on import

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Foreign key constraint violation on import in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bostonguy@gmail.com
 
Posts: n/a

Default Foreign key constraint violation on import - 09-01-2006 , 04:44 PM






I posted this on the Integration Services board, but figured the answer
to my problem might not depend on whether I am using SSIS or DTS.

Scenario:
I have a SSIS package that loads a flat file to a SQL Server database
via an OLE DB Destination object. The flat file contains a column,
which has a FK constraint on it. If the FK does not exist in the
primary table, SQL Server "throws" a FK constraint error and the entire

transaction is rolled back. I am executing the SSIS package
programmatically from a C# web form and as such, I am reporting the
error back to end user via the web page.

Questions:
How might I report back which specific record caused the error?
Does SQL Server provide this information? If not, any ideas on who to
pre-process the file to detect errors before trying to insert it?


These flat files are large so its important to report the exact problem

that caused the constraint violation.


TIA for your help.


Reply With Quote
  #2  
Old   
Arnie Rowland
 
Posts: n/a

Default Re: Foreign key constraint violation on import - 09-01-2006 , 04:51 PM






For a more 'robust' import process, I suggest that you first import the data
to a 'staging' table. Then any necessary data clean-up and modifications can
be done. The data can be checked for constraint consistency, and conforming
data can be moved to the production tables, leaving the non-conforming data
to be moved to an 'Exceptions' table for further inspection.

SSIS will be quite able to manage such a process for you.

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


<bostonguy (AT) gmail (DOT) com> wrote

Quote:
I posted this on the Integration Services board, but figured the answer
to my problem might not depend on whether I am using SSIS or DTS.

Scenario:
I have a SSIS package that loads a flat file to a SQL Server database
via an OLE DB Destination object. The flat file contains a column,
which has a FK constraint on it. If the FK does not exist in the
primary table, SQL Server "throws" a FK constraint error and the entire

transaction is rolled back. I am executing the SSIS package
programmatically from a C# web form and as such, I am reporting the
error back to end user via the web page.

Questions:
How might I report back which specific record caused the error?
Does SQL Server provide this information? If not, any ideas on who to
pre-process the file to detect errors before trying to insert it?


These flat files are large so its important to report the exact problem

that caused the constraint violation.


TIA for your help.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.