473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

BCP import then export

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..databasetable out "c:\Documents and Settings\Administrator\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..databasetable in c:\Documents and Settings\Administrator\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\Administrator\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
Feb 24 '08 #1
3 5535
debasisdas
8,127 Expert 4TB
The error message suggests you are importing data to a table and by this process making some primary key violation. ie--trying to insert a duplicate value into the table.
Feb 25 '08 #2
radcaesar
759 Expert 512MB
Hey, You had exported the values first time and the second time you are trying to insert duplicate values and that violates key.

Truncate the table and then try...
Feb 25 '08 #3
ck9663
2,878 Expert 2GB
The rows that you just exported is still on the table. When you BCP-in, it will not delete those existing rows and just add the ones you just imported. Which makes everything a duplicate. Since the table has a duplicate primary key constraint/check, maybe through an index, it gives you the error.

-- CK
Feb 25 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
0
by: minjie | last post by:
Hello, I have to implement the following requirement: from an application, a user can export some info retrieved from DB2, and later import the info into another DB2 on another machine. The user...
2
by: Siu | last post by:
Hi, I use the following code to export and import a file Excel from resp. into a Web page with the following code: //EXPORT Response.Clear(); Response.Buffer = true; Response.ContentType =...
3
by: Iavor Raytchev | last post by:
Hello, We a situation with a central database that contains the data that needs to be presented at N off-line terminals (N can be 5 000 can be 15 000). Each terminal presents unique data. The...
10
by: Niklas | last post by:
Hi Before I start coding I need to be sure that nobody else has not done it yet and that I can use it. I need an import utility which import data from Excel to a database or some object in...
0
by: jen78 | last post by:
Hi, I am new to Oracle administration and hope someone can help me out on this as i am struggling to make it work.... I am doing development work using oracle database on my own development...
1
by: InvestorTrade | last post by:
Hi, I've been trying to export/import a table from a DB with Chinese_PRC_CI_AS collation, and I can't seem to get it working at all - the export seems rather simple, it is the import that is not...
0
by: A3AN | last post by:
Hi. I receive a database backup on a daily basis. I then import this dump on another server which I use for software development. There is two db's being hosted on this server. We test software...
4
by: Max2006 | last post by:
Hi, We are developing a SQL server based asp.net application. As part of requirement we should allow users import/export some relational data through web user interface. We are investigation...
3
by: sumanta123 | last post by:
Hi All, I am using this command exp dev/dev@uatdb file='C:\database\dbbackup.dmp' for export the data from my database.It is successfully export into the dbbackup.dmp file. While import...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.