I setup a SQL server agent job that runs a stored procedure at a specific time. Once the stored procedure is done running, how can I export the results to a Tab Delimited file?
I'm using SQL Server 2008 R2.
Thanks
I setup a SQL server agent job that runs a stored procedure at a specific time. Once the stored procedure is done running, how can I export the results to a Tab Delimited file?
I'm using SQL Server 2008 R2.
Thanks
If you have xp_cmdshell enabled and if your account has access you could try:
EXEC xp_cmdshell 'bcp "SELECT * FROM tblName" queryout "C:\tblNameData.txt" -T -c
Another way is to do it as @Neil mentioned: SSIS. Here's a link:
http://decipherinfosys.wordpress.com/2008/07/23/ssis-exporting-data-to-a-text-file-using-a-package/
For this specific task, I would use SSIS, purely for its ease.
bcp
is another alternative using a file format.