Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2002

    Unanswered: 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

    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


  2. #2
    Join Date
    Sep 2002
    Hong Kong
    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.

  3. #3
    Join Date
    Mar 2002
    thanks so much, I'll try it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts