We work a lot with SQL Server and the related software suite (SSIS, SSRS in particular, in version 2008 R2). Besides that, we have developed an intranet and PHP/MySQL. As a result, we regularly need to launch an Integration Services package from a PHP page. This article gives one of the possible ways to be able to execute an SSIS package from a PHP page, with the additional possibility of being able to have a history of the different executions.
The principle is actually very simple.
To launch an SSIS package, there are several options:
- Schedule through a SQL Server agent job the triggering of the package at regular intervals
- Launch it on trigger (on request)
To launch our SSIS package from a PHP page, we will proceed as follows:
- Creation of a job on the SQL Server agent that launches the desired SSIS package. We are not planning this job.
- Creation of a SQL Server procedure that will contain the following line, allowing to launch the job that we have just created:
EXEC sp_start_job @job_name = ‘nameDuJobCree’, @server_name = ‘nomDuServeur’
- We will then call the procedure from the PHP code
The advantage of going through the job is that you will then be able to have a trace of the different executions in the job history. It’s also cleaner than running the DTSExec executable through a command line call.