devxlogo

Running a DTS Package Through TSQL with a COM Concept

Running a DTS Package Through TSQL with a COM Concept

What if you wanted to use a COM object through TSQL Statement? SQL Server facilitates this task by provding a few system sorted procedures like sp_OACreate, sp_OAMethod, etc.

Check out the example below for how to execute a DTS package. It includes declaration, creation of an object, and uses the object methods “LoadfromStorageFile” and “Execute.”

--Declaring variableDECLARE @objdts int --Creating objectEXEC sp_OACreate 'DTS.Package', @objdts OUTPUT --Loading DTS storage file to objectEXEC sp_OAMethod @objdts, 'LoadFromStorageFile', NULL, 'C:MyDTS.dts', '' --Executing DTS package through an objectEXEC sp_OAMethod @objdts, 'Execute'
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist