2012年3月8日星期四

bcp has primary key contraint error

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? Th
e 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 obje
ct 'table_name'.
SQLState = 01000, NativeError = 3621
Warning = [Microsoft][ODBC SQL Server Driver][SQL Server]The sta
tement has been terminated.
BCP copy in failedHi
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[/v
bcol]
PRIMARY KEY constraint 'table_name'. Cannot insert duplicate key in object
'table_name'.[vbcol=seagreen]
> SQLState = 01000, NativeError = 3621
> Warning = [Microsoft][ODBC SQL Server Driver][SQL Server]The statement
has
been terminated.
> BCP copy in failed
>

没有评论:

发表评论