Reputation: 380
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:
C:\Windows\System32\cmd.exe
as the action with the argument /c C:\scripts\My_query\my_process.bat
to make sure the entire process runsUpvotes: 2
Views: 1783
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