Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Export Data in Text File Using BCP

By Manish Mathur, 2011/04/20

This script export the data in text file from sql server 2005 tables. This script containing stored procedure which required four input parameters as follows :-

@DBName - Pass database name

@TableName - Pass Table name for export

@FilePath - pass valid path with file name

@Separator - pass field separator(if you pass null then it will take ',' as default separator)

In this article i have used bcp command which is required some xm_cmdshell configuration enabled in your server.

To enable to xp_cmdshell on your server execute following script :

RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE

Total article views: 4343 | Views in the last 30 days: 11
 
Related Articles
FORUM

xp_cmdshell execute scripts that are on c:

xp_cmdshell execute scripts that are on c:

FORUM

xp_cmdshell

xp_cmdshell

ARTICLE

Trading in xp_cmdshell for SQLCLR (Part 2) - Export Data to Flat Files

Learn how SQLCLR can be used to replace BCP and xp_cmdshell to export data to comma separated and ta...

FORUM

xp_cmdshell

xp_cmdshell bcp queryout

FORUM

exec master..xp_cmdshell

exec master..xp_cmdshell

Tags
bcp    
sql server 2005    
 
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