Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bcp help

Status
Not open for further replies.

ptheriault

IS-IT--Management
Aug 28, 2006
2,699
US
I have a used the bcp command to copy 4 millions rows out of a table to a .dat file. I zipped it and coppied it to another server that I am going to bcp the data back in. The database and table names and schemas are all the same. When I try to bcp the data back in it asks me to define each field. Is there are way around this.
This is the syntax I am using.
Code:
bcp mavresource.dbo.cumulative_claim in d:\dba\ce.dat -Usa -P** -SMavStg


- Paul
- Database performance looks fine, it must be the Network!
 
Thanks Denis. Those flags did the trick.

- Paul
- Database performance looks fine, it must be the Network!
 
do you know what each flag does?


- Paul
- Database performance looks fine, it must be the Network!
 
yes

Code:
Bulk copy option bcp utility switch BULK INSERT clause 
Character mode format -c DATAFILETYPE = 'char' 
Field terminator -t FIELDTERMINATOR 
Row terminator -r ROWTERMINATOR

Denis The SQL Menace
SQL blog:
 
thanks again Denis

- Paul
- Database performance looks fine, it must be the Network!
 
one more question Denis.
What does the \n do?


- Paul
- Database performance looks fine, it must be the Network!
 
For some reason the copy starts then just stops with the following..

0 rows copied
Network packet size: 4096
clock Time (ms.) : 53578

It's not importing the data?

- Paul
- Database performance looks fine, it must be the Network!
 
Here is an example of one row

WC0001244-02 141374731012004 2000-01-26 00:00:00 2001-01-26 00:00:00 2000-11-30 00:00:00 35513 AR 750.0000 633.1500 3000.0000 2540.9600 161.2300 191.0000 356.2700 422.0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 -19.4100 -23.0000 .0000 .0000 .0000 .0000 .0000 .0000 135.0600 160.0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 .0000 24011 .0000 .0000 REN 1018043402 285761


- Paul
- Database performance looks fine, it must be the Network!
 
I used bcp out like this.

Code:
bcp mavresource.dbo.cumulative_claim out ce.dat -Usa -P** -SServername

Should I have used a flag with this for format?


- Paul
- Database performance looks fine, it must be the Network!
 
use this one for out

-c

Performs the bulk copy operation using a character data type. This option does not prompt for each field; it uses char as the storage type, no prefixes, \t (tab character) as the field separator, and \n (newline character) as the row terminator.


Denis The SQL Menace
SQL blog:
 
Thanks Denis,
I'm going to go home and continue to work on this.
it's 5 O'clock...
Time to crack open a beer!


- Paul
- Database performance looks fine, it must be the Network!
 
Denis,
Thanks for your help today. This Buds for you! I got the BCP to work.

- Paul
- Database performance looks fine, it must be the Network!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top