Automating Task by using SQLCMD and Windows Scheduled Task


In a lot of situations we may not have permissions to use SQL Server Agent for automations of our back-end processes. I built a run-around that uses a Windows Scheduled Task, SQLCMD and Stored Procedure to run task.

Work flow:
1. Windows Scheduled Task calls a .bat file at specific reoccurring time
2. .bat file executes SQLCMD
3. SQLCMD creates a connection to SQL Server and executes the SP

Scheduled Task

ScheduledTask

SQLCMD

SQLCMD

Stored Procedure

StoredProcedure
Warring: If the connection between the machine that triggers the Scheduled Task and the SQL Server is interrupted during the execution of the SP, it does not end.

Keep it simple :-)

Leave a comment

Your email address will not be published. Required fields are marked *