SSIS – Configuring SSIS Package to run job after data loading has completed
- In our example below, we are going to be using a SharePoint 2013 Data Alert job which was created in SQL Server Agent, and then insert this into an existing
SSIS
Project.
- The reason for doing this, is so that every time our SSIS Project runs, as part of the process, it can then fire off a SQL Server Job.
- Essentially in the past the SQL Server Agent Jobs run
individually and are not tied into when our data has loaded.
-
By doing it in this manner, it enables the related job to be run after every data load. Which then enables the business to get the relevant data at the relevant times.
NOTE: You can modify this for any SQL Server Job.
Find the related SQL Server Agent Job Name
Below details how to find the related SQL Server Agent Job name. As typically when you create a SharePoint Data Alert, or SQL Server Reporting Services (SSRS) Data
Driven Subscription or Email Subscription, it creates the job name with a GUID.
This makes it rather difficult to find the correlating Job Name.
- The easiest way to find the SQL Server Agent Job Name, is once you have created your SharePoint Data Alert, or SSRS (Data Driven Subscription or Email Subscription) is to go directly into your SQL Server Agent Job Monitor where the Job was created.
- Then open the Job Activity Monitor
-
Then scroll through the list until you find a job with the following
properties
-
The name will be in a GUID format:
-
The Last Run Outcome is set to Unknown
- And the Last Run is set to never
- And the Last Run is set to never
-
NOTE: If there is more than one job with the above properties, then look to see when you scheduled the start time of your
job.
- If that still does not help you might have to go into the job
properties and into the schedules to see how often it runs to find the correct job.
- If that still does not help you might have to go into the job
-
- If this is in a Test
environment, you can try and run the job to ensure that you do have the correct job.
-
Make a Note of the Name of the Job
- In our example it was: 68CAE336-3D38-42A6-9526-F32F4D501AA4
- In our example it was: 68CAE336-3D38-42A6-9526-F32F4D501AA4
Modifying the SQL Server Agent Job
Below are the steps to modify the SQL Server Agent job, so that it will not run on a schedule.
NOTE: The reason we are doing this is because we want the job to be run from within our SSIS Project after it has loaded our relevant data.
-
Go into the properties of your SQL Server Agent Job and click on the Schedules
Page
- Then in the Schedule
List
click on the Schedule and select
Remove.
-
Once completed there will now not be any schedules for the job.
- Then click Ok.
Creating and configuring your SSIS Package to run the SQL Server Agent Job for you
Below are the steps to create and configure your SSIS package to run the SQL Server Agent Job as part of the SSIS Project.
- Create your new SSIS Package.
- Drag in an Execute SQL Task
-
We renamed our Execute
SQL
Task to the following:
Run SharePoint Data Alerts
-
Then we went into the properties.
- We then put in our Connection to our SQL Server Database, which is the same as the where the SQL Server Agent Job is
-
Then under the SQL Statement we put in the following:
EXEC msdb.dbo.sp_start_job N’68CAE336-3D38-42A6-9526-F32F4D501AA4′ ;
-
NOTE: The thing to note here is that we are using the MSDB
Stored
Procedure to start our Job.
- And that we are using the Job
name which we noted in previous steps.
- And that we are using the Job
-
- We then put in our Connection to our SQL Server Database, which is the same as the where the SQL Server Agent Job is
- Now that you have completed your Execute SQL Task, it is time to test it.
- Right click and select Execute SQL Task.
-
If successful it should come back looking like the following below:
-
As well as actually getting the email in your Inbox, as is the case with our SharePoint Data Alert.