export select query result in to pipe delimiter Textfile

Hello Friends,

I have a table that I need to export to a pipe delimited .txt file.please follow the below step to do that things.

Steps 1: [https://amitpatriwala.wordpress.com/2010/04/02/save-select-query-result-into-textfile/]

Enabled the xp_cmdshell

By default disabled in SQL 2005 for security reasons.

To enable it, use the Surface Area Configuration tool or sp_configure

To enable xp_cmdshell using sp_configure, use below query :

EXEC master.dbo.sp_configure ‘show advanced options’, 1


EXEC master.dbo.sp_configure ‘xp_cmdshell’, 1


Steps 2:

EXEC master..xp_cmdshell ‘bcp “select * from Adbrite..Adtype” queryout “c:\text.txt” -U sa -P sa123-c -t^| -x’

Database Name : Adbrite

Table Name : Adtype

Sql User Name : sa

Sql Password : sa123

delimiter option : t^|




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s