0xc0202009 Primary Key Error

  • I keep receiving the error below when trying to import data from a Flat File source (CSV file) in SQL 2008 R2 Express edition.

    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: "The statement has been terminated.".

    An OLE DB record is available. Source: "Microsoft SQL Server Native Client 10.0" Hresult: 0x80004005 Description: "Violation of PRIMARY KEY constraint 'PK_UoSW_STAGING_TABLE'. Cannot insert duplicate key in object 'dbo.UoSW_STAGING_TABLE'. The duplicate key value is (00492FF894C64BEFAC9C3D1866773CE2).".

    (SQL Server Import and Export Wizard)

    I have checked the import source for the primary key SQL says is causing the error but when I find that primary key in the CSV file only one entity exists.

    I thought perhaps it was due to that particular record so removed this and ran the import wizard again but the same error occurs with a different field. I cannot see how I can get around this when the primary key isn't being duplicated at all.

    I have also checked other tables within the database to make sure I haven't accidentally imported the CSV to the wrong location.

    Any help would be tremendous at this stage as this has driven me insane for hours!

  • Have you checked the contents of the table? If it already exists and has data in it, then you need to see if the duplicate values are already populated. A Primary Key violation is a pretty straight forward error!

    Follow me on twitter @EvoDBACheck out my blog Natural Selection DBA[/url]

  • Primary Key Violation error mince.. you are trying to insert duplicate rows into table.

  • Insert your data into a staging table then check for duplicates there:

    SELECT KeyColumn

    FROM StagingTable

    GROUP BY KeyColumn

    HAVING COUNT(*) > 1;

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply