Hi,
I'm not a SQL person but have the need to export a tables content (from live) and then import into a test system. A backup and restore is not an option.
bcp Database..datab asetable out "c:\Documen ts and Settings\Admini strator\My Documents\test3 .txt" -c -P
Exports ok (I would like to export the tables column headers aswell), but if I try to reimport this file on the same server using
bcp Database..datab asetable in c:\Documents and Settings\Admini strator\My Documents\test3 .txt" -S(local) -c -P password
but I get the following error.....
Starting copy...
SQLState = 23000, NativeError = 2627
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY
constraint 'PK___2__10'. Cannot insert duplicate key in object 'ComputerEntry' .
SQLState = 01000, NativeError = 3621
Warning = [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been
terminated.
BCP copy in failed
C:\Documents and Settings\Admini strator\My Documents>Pause
Press any key to continue . . .
Why does export and import fail on the same server (I'm testing on my test system)
I'm afraid this error means little and the more I search google the more confused I get !!
Thanks inadvance
Paul
I'm not a SQL person but have the need to export a tables content (from live) and then import into a test system. A backup and restore is not an option.
bcp Database..datab asetable out "c:\Documen ts and Settings\Admini strator\My Documents\test3 .txt" -c -P
Exports ok (I would like to export the tables column headers aswell), but if I try to reimport this file on the same server using
bcp Database..datab asetable in c:\Documents and Settings\Admini strator\My Documents\test3 .txt" -S(local) -c -P password
but I get the following error.....
Starting copy...
SQLState = 23000, NativeError = 2627
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Violation of PRIMARY KEY
constraint 'PK___2__10'. Cannot insert duplicate key in object 'ComputerEntry' .
SQLState = 01000, NativeError = 3621
Warning = [Microsoft][ODBC SQL Server Driver][SQL Server]The statement has been
terminated.
BCP copy in failed
C:\Documents and Settings\Admini strator\My Documents>Pause
Press any key to continue . . .
Why does export and import fail on the same server (I'm testing on my test system)
I'm afraid this error means little and the more I search google the more confused I get !!
Thanks inadvance
Paul
Comment