Export SQL to Text

Oddly I heard this question today.  It has been awhile but thought I would note for others for future reference the bcp command:

For a comma separated file:
From your sql server management studio run the below:
 
declare @sql varchar(8000)
 
SELECT @sql = ‘bcp “select * from [dbname]..[table name]” queryout c:\temp\mytest.txt -c -t, -T -S [server name]‘
 
exec master..xp_cmdshell @sql

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.