clarked
clarked

Reputation: 380

Scheduled Task Runs .bat File with sqlcmd, but Doesn't Update the Output File

My scheduled task (on Windows Server 2008 R2) is "successfully" running each morning, but the output of sqlcmd does not get updated in the output file. The log file changes to show that the batch file ran, but the output file remains the same.

When I run a .bat file with the lines of code below, it works just fine. The .csv file gets updated with the most recent query's results.

sqlcmd -S SERVERNAME -i my_query.sql -s "," -o c:\scripts\My_query\query_results.csv -W -h-1

ftp.exe -s:"c:\scripts\My_query\file_upload.ftp"

Useful Information:

Upvotes: 2

Views: 1783

Answers (1)

Squashman
Squashman

Reputation: 14320

Are the tasks configured to run whether the user is logged on or not? If so, it will never find your SQL file because the default working directory is SYSTEM32 when you configure a scheduled task that way. You will need to provide the full path to the SQL file.

Upvotes: 3

Related Questions