ahthomas (1/2/2013)
I have a script that writes data to a temp table. I need to automatically export this to a csv located at a UNC destination. How do I write this into the SQL script? A retention period in this would also be nice...
TSQL doesn't have a native ability to export to disk; you have to use something like xp_cmdshell to call bcp.exe or some other component
You can also use a CLR function like this one:http://sqlclrexport.codeplex.com/
There's a connect item that will never be fulfilled asking for a the export equivalent of BULK INSERT, but MS says they will not complete the request.
http://connect.microsoft.com/SQL/feedback/ViewFeedback.aspx?FeedbackID=224026
Lowell