Apr 30, 2008

How to run DTS from Stored Procedure

You can run DTS package from the client PC by these ways.

  • Run DTSRUN.exe (It is provided as DTS utility.)
  • Call the method in DTS object
  • Call stored procedure (Stored procedure is necessary to be prepared in server side.)
The first 2 ways are necessary to install component in client. So I'll introduce the last way this time. There are two ways to run DTS from stored procedure.

Run DTS by xp_CmdShell

  1. Create the command file (.bat or .vbs and so on) to execute DTSRUN
  2. Create the stored procedure to call xp_CmdShell to execute the command file which is created in step1
  3. Call the stored procedure

Run DTS by SQLServer Agent

  1. Create SQLServer Agent job to run DTSRUN
  2. Create the stored procedure to call sp_start_job
  3. Call the stored procedure
CREATE PROCEDURE [ExecuteDTS_TestPackage] AS
EXECUTE msdb..sp_start_job @job_name = 'TestPackage'

GO

No comments: