SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Export Data in Text File Using BCP

By Manish Mathur, 2009/02/11

Total article views: 2085 | Views in the last 30 days: 73

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

By Manish Mathur, 2009/02/11

Total article views: 2085 | Views in the last 30 days: 73
Your response
 
 
Related Articles
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

Separating Report Server

Using a separate server for external reporting

FORUM

exec master..xp_cmdshell

exec master..xp_cmdshell

FORUM

Alternative to using xp_cmdshell

Avoiding using xp_cmdshell

Tags
bcp    
sql server 2005    
 
Contribute

Free registration required...

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Login (existing users)

Login

Email:   Password:   Remember me: Forgotten your password?

Register (new users)

Register

Email:   Password:
Confirm:

Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

Steve Jones
Editor, SQLServerCentral.com