Schedule Windows Service or Console App using Microsoft SQL JOB

What is a SQL JOB?

Let me explain, a JOB is a specified series of actions that an SQL server agent performs. Use JOBs to define an administrative task and it can be run one or many as times and monitored either success or failure. A SQL JOB can run on one local or multiple remote servers. That’s it.

NOW! Suppose we want to run a Windows application on a specific time interval.

Especially, There is one way to create a job scheduling using Quartz, and here I am going to introduce another way that is not commonly used using SQL Jobs.

Most Noteworthy, Here I am going to introduce one other way that is not well known among some .Net developers. This is by creating a schedule JOB in Microsoft SQL Server.

Here I am going to explain to you some steps for the run application using jobs. Follow the steps.

  1. Publish your Windows application or console application.
    SQL JOB
  2. Open Microsoft SQL server management studio navigate to SQL Server Agent and find Job.
  3. Right-click on Job Folder click on New Job and fill in general details.
    SQL JOB
  4. Now on left navigation on new job window click on steps and click on the New button at the bottom.
    SQL JOB
  5. The above steps will open a new window “New Job Step”, write the steps name, and select “Type: Operating system (CmdExec)”.
  6. Now in the command window copy the full path of the ex, you would like to execute and save this step. All the above 1-6 steps are responsible for defining which job to execute still, we have to define at what time/interval.
  7. Not to make it schedule click on “Schedules” in the New Job window under Steps and click on the New button.
    SQL JOB
  8. After clicking a new button it will open the New Job Schedule where the SQL server is full with a lot of options on which frequency you would like to run your application.

That’s all you have to follow only 8 easy steps and your schedule will start working with the SQL server.

There is one advantage of this kind of approach, NET server developers can easily call this job from stored procedure or code itself by executing the command “exec msdb.dbo.sp_start_job N’youjobname’”

I hope that this blog will help you. If you like my blog then you can share it on social with your friends.

Article by

Chintan Prajapati

Chintan Prajapati, a seasoned computer engineer with over 20 years in the software industry, is the Founder and CEO of Satva Solutions. His expertise lies in Accounting & ERP Integrations, RPA, and developing technology solutions around leading ERP and accounting software, focusing on using Responsible AI and ML in fintech solutions. Chintan holds a BE in Computer Engineering and is a Microsoft Certified Professional, Microsoft Certified Technology Specialist, Certified Azure Solution Developer, Certified Intuit Developer, and Xero Developer.Throughout his career, Chintan has significantly impacted the accounting industry by consulting and delivering integrations and automation solutions that have saved thousands of man-hours. He aims to provide readers with insightful, practical advice on leveraging technology for business efficiency.Outside of his professional work, Chintan enjoys trekking and bird-watching. Guided by the philosophy, "Deliver the highest value to clients". Chintan continues to drive innovation and excellence in digital transformation strategies from his base in Ahmedabad, India.