How to create SQL Server Agent Jobs on a Linux based instance using Management Studio
SQL Server Agent support is included with the release of SQL Server vNext CTP 1.4. Now DBAs and users can schedule any task using a SQL Server Agent Job. I have explained how to create SQL Server Agent Jobs using T-SQL commands in a recent tip. In this tip, I will explain how to create and run SQL Server Agent Jobs using SQL Server Management Studio.
There is no difference between creating jobs on a Linux based SQL Server and a Windows based SQL Server using SQL Server Management Studio (SSMS). The prerequisite to create and run jobs is to have SQL Server Agent installed on your SQL Server instance. I have explained the step by step process to install SQL Server Agent on Ubuntu server in a recent tip. SQL Server Agent Jobs are very useful for automating of any kind of repetitive task. You can get the full list of features and known issues at this Microsoft link: SQL Server on Linux Release Notes.
SQL Server Agent Job Creation using Management Studio
Before going ahead, you need to have SQL Server vNext running on your Linux based SQL Server. Also make sure that you have installed SQL Server Agent on this box to create jobs.
Step 1: First, connect to your Linux based SQL Server using SSMS from a Windows client. Enter the Linux server name/IP, then choose SQL Server authentication to enter the sa login and password. Click on the connect button to establish a database connection from the Windows client.
You can see we have now connected to our target SQL Server machine.
Step 2: Now expand SQL Server Agent folder. You can see all the sub folders under SQL Server Agent folder. Right click on "Jobs" folder and choose "New Job..." to start the new job creation.
Step 3: Once you click on the "New Job..." option the interface below will load. Complete the details including the name and description in the General tab of the interface.
Step 4: Now click on second tab "Steps" from left pane. You will get the below interface to add a new step.
Click on "New" tab to add the step details. Once you click on the "New" button the below screen will appear to complete the step details. Enter the details as per your need. I am running a full backup for one of my databases, so I selected "Transact-SQL script (T-SQL)" as the Type and entered the T-SQL code which will be executed.
Once completed press the "OK" button to proceed. The will look like the screen shot below.
Step 5: Now click on third option "Schedules" from the left pane.
Click on "New" button to create a new schedule. You will get an interface similar to the below image. Enter the details as I have shown below to run the backup job on a daily basis.
Once you entered all the details click the "OK" button to proceed.
Step 6: Now you can check the job history to verify that this job has not run before. Right click on the Job name and select the View History option.
Now go ahead and run this job. Right click on newly created backup job and click "Start Job at Step".
If the job successfully executes the window below will indicate success.
Step 7: Now we will validate the job success. We can check the job history as shown in the below image and can see backup job has been executed successfully.
The final validation step is to check the newly created backup file on the Linux server. We can check the backup file location and we can see the newly created file.
- Check out the following resources:
Last Updated: 2017-07-12
About the author
View all my tips