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

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Export Data in Text File Using BCP

By Manish Mathur,

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: 4649 | Views in the last 30 days: 2
 
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