broke
broke

Reputation: 8302

SQL Server Agent Job - Export results to Tab Delimited File?

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

Upvotes: 2

Views: 17172

Answers (2)

Nonym
Nonym

Reputation: 6299

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/

Upvotes: 1

Neil Knight
Neil Knight

Reputation: 48537

For this specific task, I would use SSIS, purely for its ease.

bcp is another alternative using a file format.

Upvotes: 4

Related Questions