Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 7364 | Views in the last 30 days: 9
 
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

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones