Maybe this will get you started:
http://weblogs.sqlteam.com/brettk/archive/2005/04/13/4395.aspx
EDIT:
The example uses BCP, and to get it to work you may have to reconfigure some features. I ran the following simpler example (which will export data without headers) to better understand what BCP does:
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
-- Dump the table
DECLARE @sql VARCHAR(8000)
SELECT @sql = 'bcp <database>.dbo.<table> out d:\bcp\output.txt -c -t, -T -Slocalhost'
EXEC xp_cmdshell @sql