title: Bat file to run a sql query on a schedule through Task Scheduler
body: <p>I am trying to run a .sql script on a schedule. I have created a batch file to run the script. The script runs fine in sql server management studio and also when I run the batch file content through cmd. </p>
  
  <p>Contents of the batch file: </p>
  
  <pre><code>sqlcmd -S omfmesql -U OMESRV -P orat -i "\\pvsrv-
  fsr14\data\Projects\Stat_Table_Creation_unique.sql"
  </code></pre>
  
  <p>The sql script is supposed to update a stat table. When I run it though cmd and refresh the stat table, the numbers are updated. But when I run this batch file through Task Scheduler, the only action that seems to be performed is running C:\Windows\SYSTEM32\cmd.exe</p>
  
  <p>The task is stated to be completed successfully but the sql query is just not run. </p>
  
  <p>I am not too experienced with Task Scheduler. Any help here would be very much appreciated. Thanks!</p>
  
  <p>Note: I am not intending to use SQL Server Agent</p>