Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 bcp out of 10 tables

Author  Topic 

sql_server_dba
Posting Yak Master

167 Posts

Posted - 2011-01-10 : 11:29:40
All,

Can anyone please let me know how we can bcp out of 10 tables at a time. Currently i am doing one at a time using the below command in cmd prompt...

bcp databaseName..tableName out "c:\tableName.txt" -c -T -S SERVERNAME

i am not sure how i can write the whole 10 bcp outs in a text file and execute it. Can someone let me know how to do this?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-10 : 11:32:58
you mean append the same file with result merged from ten identical structured tables?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sql_server_dba
Posting Yak Master

167 Posts

Posted - 2011-01-10 : 11:50:18
Thanks for the prompt response.
what i want is i have 10 different tables and i want extract them using bcp. I am able to do for one table in cmd prompt. But what do i need to do to extract all of them at a time?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-10 : 11:51:48
sorry still not completely clear

extract all 10 tables data to single file? also are they of same structure?
or extract them to 10 different files at same time?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sql_server_dba
Posting Yak Master

167 Posts

Posted - 2011-01-10 : 11:57:39
sorry..i want them to extract them to 10 diff files at a time. their structure is completely different.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-10 : 11:59:33
why dont you wrap all of them inside a stored proc and then call it to do all of them at once?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sql_server_dba
Posting Yak Master

167 Posts

Posted - 2011-01-10 : 12:02:50
i want to do this using command prompt...i cannot use xp_cmdshell.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-10 : 12:10:03
create a batch file containing all the bcps and then execute the batch file from command prompt

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sql_server_dba
Posting Yak Master

167 Posts

Posted - 2011-01-10 : 12:26:53
yeah..but i am not so familiar with batch file and how it works. Could you please let me know how it works?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-10 : 12:38:33
see

http://support.microsoft.com/kb/176818

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -