If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > BCP help please!!

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-05-03, 15:00
Wale Wale is offline
Registered User
 
Join Date: Mar 2002
Posts: 162
BCP help please!!

I would like to bulk copy 37 tables out of my development db server

I know how to write a batch file to bulk copy one table for example below I copy the opp_data table in the ipabs database.etc

d:
cd syb_dump
del /q d:\ipabs_ftp\login.dat
bcp ipabs..opp_data out opp.dat -Usa -PMORPHEUS1 -Sipabs -c
move opp.dat d:\ipabs_ftp\opp.dat

My question is how do I copy all 37 tables to the same output file
what adjustments would I have to make to the above script

THANKS
'W
Reply With Quote
  #2 (permalink)  
Old 03-10-03, 17:39
richardcrossley richardcrossley is offline
Registered User
 
Join Date: Sep 2002
Location: Dublin, Ireland & Woking UK
Posts: 150
I'll assume you're using Windows NT (2000 works and XP should as well) somewhere, because the following won't work on Win 85, 98, or ME

@echo off
echo. > all_tables.txt
for /f %%t in (tables.txt) do (
echo %%t
bcp rwc..%%t out %%t.txt -Uuser_name -Sserver_name -Ppassword -c
copy all_tables.txt + %%t.txt all_tables2.txt
del all_tables.txt
move all_tables2.txt all_tables.txt
)

This will work for any number of tables. Just put each table on its own line in a file called "tables.txt". Obviously you will need to specify your user name, server name and password.

The resulting file is called "all_tables.txt" There is a blank line at the start of the file, but I think that's a small price to pay.

If you're going to be doing this kind of thing regularly think about obtaining Cygwin becuase then you have a more powerful scripting (bourne shell) at your disposal.
Reply With Quote
  #3 (permalink)  
Old 03-11-03, 10:48
Wale Wale is offline
Registered User
 
Join Date: Mar 2002
Posts: 162
thanks so much, I'll try it.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On