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




Stored Procedure

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 :-)

About Peter Lalovsky

I am Microsoft SQL Server certified professional, creating with T-SQL, SSRS, SSIS, ASP.NET/C#, Azure, Python, PowerShell and more on a daily basis since year 2006. In 2016 i wrote a book for beginner and intermediate T-SQL programmers which you can download here. This blog is something like my personal programming documentation. When i am not in front of a computer, i am around my paper car – Trabant 601.

Leave a comment

Your email address will not be published.