Violation of PRIMARY KEY constraint error on import of Data - duplicates

I have a table in SQL Server called Services. It has a primary key on the Service_ID field.
I deleted some data and am trying to reimport data from a CSV file.
I am getting the errors below. It mentions a violation of Primary Key.
However if I query the table searching for a record with that Service_ID value then it does not find it - results are empty. So why am I getting this error?
Copying to [dbo].[Services] (Error)
Messages
Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'PK_Services'. Cannot insert duplicate key in object 'dbo.Services'. The duplicate key value is (538629).".
(SQL Server Import and Export Wizard)
Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Destination - Services.Inputs[Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "Destination - Services.Inputs[Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Destination - Services" (90) failed with error code 0xC0209029 while processing input "Destination Input" (103). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
Error 0xc02020c4: Data Flow Task 1: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - Services_csv returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)

Duplicate key was in my import data not the table.

Related

job ssis in ssms versus local solution

I have a job ssis that truncate a table and insert into this table.
When i launch the package in visual studio, all works well but when I put the job on sql server and launch it with ssms, it doesn't works. there is a primary key conflict when inserting..so i'm asking why its working in visual studio and not on sql management studio..
I log one table after the truncate and the count return 0 rows..so the truncable command works well.
I use the same user to launch the package in visual studio or ssms.
I use ole db datasource and destination.
here is the complete error message :
Executed as user: DOMAIN\USER. Microsoft (R) SQL Server Execute Package Utility Version 13.0.5149.0 for 64-bit Copyright (C) 2016 Microsoft. All rights reserved. Started: 14:46:04 Error: 2018-10-11 14:46:08.01 Code: 0xC0202009 Source: Data Flow Component OLE DB Destination [104] Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "The statement has been terminated.". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'PK_STA_TABLE'. Cannot insert duplicate key in object 'dbo.STA_TABLE'. The duplicate key value is (19).". End Error Error: 2018-10-11 14:46:08.01 Code: 0xC0209029 Source: Data Flow Component OLE DB Destination [104] Description: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "OLE DB Destination.Inputs[OLE DB Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "OLE DB Destination.Inputs[OLE DB Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure. End Error Error: 2018-10-11 14:46:08.01 Code: 0xC0047022 Source: Data Flow Component SSIS.Pipeline Description: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "OLE DB Destination" (104) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (117). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure. End Error Error: 2018-10-11 14:46:09.50 Code: 0xC02020C4 Source: Data Flow Component Data Source T_TABLE [2] Description: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020. End Error Error: 2018-10-11 14:46:09.50 Code: 0xC0047038 Source: Data Flow Component SSIS.Pipeline Description: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Data Source T_TABLE returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 14:46:04 Finished: 14:46:10 Elapsed: 5.781 seconds. The package execution failed. The step failed.
Thank you.

SSIS OLE Destination several error output

I have a problem...
I have an OLE DB error that occurred in INSERT statement than conflicted with the FOREIGN KEY constraint.
SSIS package eturn this 3 errors:
[OLE_DEST PollOptionUserResult [43]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "The statement has been terminated.".
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "The INSERT statement conflicted with the FOREIGN KEY constraint "FK_PollOptionUserResult_PollUserResult". The conflict occurred in database "dw_ismsES", table "ten.PollUserResult", column 'PollUserResultID'.".
[OLE_DEST PollOptionUserResult [43]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "OLE_DEST PollOptionUserResult.Inputs[OLE DB Destination Input]" failed because error code 0xC020907B occurred, and the error row disposition on "OLE_DEST PollOptionUserResult.Inputs[OLE DB Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "OLE_DEST PollOptionUserResult" (43) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (56). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.
When I try redirect error to my error_table, it internally for some reason take the last one and no the first one I need.
How I can obligate it to take the first one error?
In my case (SSIS 2008), I created an OnError event in the package level, so every error happening in the package would be logged, regardless of where they happened. When I take this approach, all 3 errors should be logged in my error table. I.e.
Please try this approach and see what you get.

Importing Microsoft Access file into SQL Server?

I tried to import a Microsoft Access file into SQL Server 2012.
Error:
Copying to [dbo].[Placements] (Error)
Messages
Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "Invalid date format".
(SQL Server Import and Export Wizard)
Error 0xc020901c: Data Flow Task 1: There was an error with Destination - Placements.Inputs[Destination Input].Columns[LastTimeDate] on Destination - Placements.Inputs[Destination Input]. The column status returned was: "Conversion failed because the data value overflowed the specified type.".
(SQL Server Import and Export Wizard)
Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Destination - Placements.Inputs[Destination Input]" failed because error code 0xC020907A occurred, and the error row disposition on "Destination - Placements.Inputs[Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Destination - Placements" (97) failed with error code 0xC0209029 while processing input "Destination Input" (110). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
Error 0xc02020c4: Data Flow Task 1: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Source - Placements returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
Check the [LastTimeDate] column in the Access table to see if it contains any dates prior to January 1, 1753. If so, then you'll either have to fix those dates (if they are incorrect) our you'll have to tweak the column type mapping during the import to ëdit mapping for that column [LastTimeDate] with Datatype as datetime2 (instead of a datetime column) in the SQL Server table column mapping.
Also another thing i had come across during a DB migration from Access to SQL is if the date Column was having a wrong format example :Instead of date value it was '00:00:00' so i checked through the entire Access DB for that Column containing Date values if the value was just '00:00:00' and replaced it with blank. and then migrated the DB from access to SQL .
Successful migration . It did work. try it out.
Sort your table by the date field from the oldest to newest by date.

Import excel file in sql server 2008

I know this question might be repeated. But what I get issue with this is different. I have already created table "CRM_Doctor_Budget" with no data.
I want to insert data in this table from excel file.
I am using import and export data (32-bit).
Following step I do:
Error which I am getting :
- Validating (Error)
Messages
Error 0xc0202049: Data Flow Task 1: Failure inserting into the read-only column "Id".
(SQL Server Import and Export Wizard)
Error 0xc0202045: Data Flow Task 1: Column metadata validation failed.
(SQL Server Import and Export Wizard)
Error 0xc004706b: Data Flow Task 1: "component "Destination - CRM_Doctor_Budget" (59)" failed validation and returned validation status "VS_ISBROKEN".
(SQL Server Import and Export Wizard)
Error 0xc004700c: Data Flow Task 1: One or more component failed validation.
(SQL Server Import and Export Wizard)
Error 0xc0024107: Data Flow Task 1: There were errors during task validation.
(SQL Server Import and Export Wizard)
I am getting error in converting varchar,int,smallint,bit data type. Because excel file has general datatype for all data. And In my already created table I have varchar, int, float, smallint and bit.
After checked "Enable Identity Insert" I get less error but errors are as follow :
Copying to [dbo].[CRM_Doctor_Budget] (Error)
Messages
Error 0xc0202009: Data Flow Task 1: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005.
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Unspecified error".
(SQL Server Import and Export Wizard)
Error 0xc020901c: Data Flow Task 1: There was an error with input column "Id" (143) on input "Destination Input" (72). The column status returned was: "The value violated the integrity constraints for the column.".
(SQL Server Import and Export Wizard)
Error 0xc0209029: Data Flow Task 1: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "input "Destination Input" (72)" failed because error code 0xC020907D occurred, and the error row disposition on "input "Destination Input" (72)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
Error 0xc0047022: Data Flow Task 1: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Destination - CRM_Doctor_Budget" (59) failed with error code 0xC0209029 while processing input "Destination Input" (72). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
I have solved the problem. I had made some changes like:
In Edit Mapping : As I have ID as an identity column and it is auto generated column.
As previously I have mapped Id column.
Now This time I did not map ID column and make unchecked the "Enable I identity Insert"
Else I perform step as it is .. this minor change I have done and I get records import successfully. :) thank you all for helping.
Is the ID column an identity column? Because if it is, you need to click the "Enable Identity Insert" checkbox to get this to work.

Importing from Oracle to SQL

I am trying to import a table from Oracle into SQL server 2008 using .net of the SQL import/export wizard, the table contains 2 million records and when it reaches 35000 it failed and generate the following error:
Error 0xc0209029: Data Flow Task 1: SSIS Error Code
DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "component "Source -
PORTRAIT" (1)" failed because error code 0x80004003 occurred, and the
error row disposition on "output column "IMAGE_DATA" (70)" specifies
failure on error. An error occurred on the specified object of the
specified component. There may be error messages posted before this
with more information about the failure.
(SQL Server Import and Export Wizard)
Error 0xc02090f5: Data Flow Task 1: The component "Source - PORTRAIT"
(1) was unable to process the data. Pipeline component has returned
HRESULT error code 0xC0209029 from a method call.
(SQL Server Import and Export Wizard)
Error 0xc0047038: Data Flow Task 1: SSIS Error Code
DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on component "Source
- PORTRAIT" (1) returned error code 0xC02090F5. The component returned a failure code when the pipeline engine called PrimeOutput().
The meaning of the failure code is defined by the component, but the
error is fatal and the pipeline stopped executing. There may be error
messages posted before this with more information about the failure.
(SQL Server Import and Export Wizard)
I need to know why it failed.
Check your data types. Specifically for the IMAGE_DATA data type. Either the source and destination don't match properly, you haven't specified the right data type during the transform, etc.
The error you are getting is around the transformation and it is barking at a data type. What is the source data type and size/precision/etc. What is the destination's? Look there more.