Running DTS Package from SQL Job Agent

How can I run the DTSRun Utility from SQLServer Job Agent

Can u specify the syntax to use DTSRun in the SQLServer Job Scheduler?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

you can make a call to dtsrun command from the command line to execute a package sql-server.
The package could be stored either in msdb, repository or a com-structured file.

The syntax would be :
1] to execute a pkg saved in a com file would : dtsrun /Ffilename /Npackage_name /Mpackage_password
2] to execute a pkg save in the msdb: dtsrun /Sserver_name /Uuser_name /Ppassword /Npackage_name /Mpackage_password
3] to exeucte a pkg save in the repository : dtsrun /Sserver_name /Uuser_name /Rrepository_name /Ppassword /Npackage_name /Mpackage_password.

specify one of the steps of your job as type : Operating System Command (CmdExec)
and the command would be any one of the 3 syntaxes above.

neelaAuthor Commented:
How do we execute these packages from VB?
Hi neela,

DTS packages could be executed from any tool which supports automation ed, vb 5 or vb 6.

From visual basic, a reference has to be made to the Microsoft DTSPackage Object Library file which is DTSPKG.RLL

Once you set the reference to it all you need to do is :

1] Instantiate an object of DTS.Package
2] Set a reference to the package by calling any of these methods LoadFromRepository, LoadFromSQLServer, LoadFromStorageFile with the appropriate parameters.
3] call the execute method of the dts package object.

Here is a sample code. I saved the package to a file ( customers.dts ) with no owner and operator password.

Private Sub Command1_Click()
 Dim objDTS As New DTS.Package
 Screen.MousePointer = vbHourglass
 objDTS.LoadFromStorageFile "c:\customers.dts", ""
 Screen.MousePointer = vbDefault
End Sub

Hope this answers your question.
If you need more post a comment.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.