Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

BCP Data Dynamically

By Brian Knight,

Here is an example of how to use the sp_msforeachtable stored procedure to bcp out data for each table:


use pubs
go

sp_MSforeachtable
@command1="master..xp_cmdshell 'bcp pubs.? out c:\? /U <user name /P <password> /S <server name> /c'"
go

For more information on sp_msforeachtable, please read the archived article.

 
Total article views: 7408 | Views in the last 30 days: 7
 
Related Articles
FORUM

sp_msforeachtable

sp_msforeachtable

FORUM

Msforeachtable

Is there a way to insert the output from the sp_msforeachtable proc in to a table. the query i am t...

FORUM

msforeachtable

How to avoid some tables while using msforeachtable? the best way is to switch to your own cursor,...

FORUM

Undocumented Stored Procedures?

sp_MSforeachdb & sp_MSforeachtable

FORUM

sp_msforeachtable

Hi all I am currently have a requirement to run some code against each table in a database and wa...

Tags
advanced querying    
scripts    
t-sql    
 
Contribute