Re: bcp has primary key contraint error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: John Bell (jbellnewsposts_at_hotmail.com)
Date: 06/08/04


Date: Tue, 8 Jun 2004 18:33:51 +0100

Hi

Try the -e option. From Books online:

-e err_file
Specifies the full path of an error file used to store any rows bcp is
unable to transfer from the file to the database. Error messages from bcp go
to the user's workstation. If this option is not used, an error file is not
created.

John

"erika" <anonymous@discussions.microsoft.com> wrote in message
news:9888AE94-88DC-499B-8EA9-E61C2A72F546@microsoft.com...
> When running a bcp to insert data into a table, I get a violation of
primary key contraint. Is there any way to tell what row is causing the
problem? The error I'm getting is:
>
> SQLState = 23000, NativeError = 2627
> Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Violation of
PRIMARY KEY constraint 'table_name'. Cannot insert duplicate key in object
'table_name'.
> SQLState = 01000, NativeError = 3621
> Warning = [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has
been terminated.
>
> BCP copy in failed
>



Relevant Pages

  • Re: Problem directing BCP Error to Error file
    ... Though the bcp in works fine but the error file is not being created ... Why are you asking questions about bcp in a Perl newsgroup? ... helped with your Perl problems a week ago, but it seems the problem you ...
    (comp.lang.perl.misc)
  • Re: Almost there with bulk insert
    ... SET ANSI_WARNINGS OFF before you do the bulk insert. ... Yes, you can specify an error file with BULK INSERT too, ... but BULK INSERT and BCP behaves differently in this case. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)
  • Re: Problem Directing BCP error to error file
    ... Though the bcp in works fine but the error file is not being created ... Query ... Stonehenge Perl Training ...
    (perl.beginners)
  • Re: Bcp in problem
    ... Yes i use the -e option however the error file is empty. ... It runs without error however terminates after 2 million records. ... "TJTODD" wrote: ... > noticed it that the bcp in process terminates when it reaches around 2.5 ...
    (microsoft.public.sqlserver.server)