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