Executing a DTS package from a stored Procedure

Hi All

How can I execute a DTS package stored on my SQL Server from a stored procedure.

Many Thanks

Who is Participating?

Improve company productivity with a Business Account.Sign Up

iamariConnect With a Mentor Commented:
in the stored proc is like:

exec master..xp_cmdshell 'DTSRun /S (local) /U sa /P  /N myPackageName', NO_OUTPUT

where User id (sa) and Password (if existing) should be provided
no_output prevents the server from sending back the "Loading... " message to user
look at dts_run and xp_cmdshell.
Or you could set the job to run under the scheduler then use sp_startjob.
oops dtsrun
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

demmickAuthor Commented:
I know of the dtsrun comand but I can't use it in the Query analyser.  I am assuming that it will work in the stored procedure if it works in the query analyser.
you can't use dtsrun directly from qa or sp, since it's a DOS command, you need to run it via xp_cmdshell (blocking) or add a job and use sp_startjob in your sp.
Read about "How can I run a DTS package from within SQL Server - e.g. a stored-procedure?"

Hope this helps
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.