Solved

How to make sure the existing record is not inserted into the table

Posted on 2014-09-16
4
159 Views
Last Modified: 2014-09-30
An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 10.0"  Hresult: 0x80004005  Description: "Violation of PRIMARY KEY constraint 'PKC_ET_Ut_Base_EmailAddress'. Cannot insert duplicate key in object 'dbo.ET_Ust_Base'. The duplicate key value is (mi05@aol.com).".

Hi experts, since I have a primary key I cannot insert the duplicate value, is there a way I can only insert records that are not in the table. I am using SSIS to load the contents of CSV file into a table, please suggest.
Thanks!
0
Comment
Question by:sqlcurious
4 Comments
 
LVL 47

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 250 total points
ID: 40325151
You can use the LOOKUP component from SSIS. What it does is to check the existence of a row and then you can define the actions for when it's true or false.
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 250 total points
ID: 40325163
If I read the question correctly (which I might not be doing, as you have given few specifics apart from the error message), you have a Flat File Source and an OLE DB Destination, and some of the export into the OLE DB fails, and you want it not to fail.

Then go into the Error Output tab of the OLE DB Destination Editor and change "Error: Fail component" to "Error: Ignore failure", or "Error: Redirect row" if you want errors to be documented.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 40326929
i would handle it differently:  Never attempt to add data directly into Production.  Instead add the data to a staging table.  you can then validate as much as you need and then and only then import in your case non-duplicate data into Production using simple T-SQL techniques (GROUP BY, DISTINCT, CTEs, etc.).
0
 

Author Closing Comment

by:sqlcurious
ID: 40353131
thanks
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBScript Write Column Headers 3 38
SSAS Hierarchy with columns with folder names 10 14
Create snapshot on MSSQL 2012 3 19
While in ##Table - Help 4 16
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question