You can run queries against a Data Transformation Services (DTS) package by using a Transact-SQL OPENROWSET statement.
To prepare a package to serve as a data source, select the DSO rowset provider check box (on the Options tab of the Workflow Properties dialog box) for a package step.
Before querying a package with OPENROWSET, consider the following:
For more information about using the Transact-SQL OPENROWSET statement, see OPENROWSET.
Suppose you want to use SQL Query Analyzer to query a package saved to the package Dso.dts on your local server. Use the following query statement:
SELECT * FROM OPENROWSET('DTSPackageDSO', '/FC:\Dts\Dso.dts', 'Select *')
In the OPENROWSET statement:
If you selected the DSO rowset provider check box for more than one Transform Data task in the above package, you can use the following code to query the second package step in Dso.dts:
SELECT * FROM OPENROWSET('DTSPackageDSO', '/FC:\Dts\Dso.dts',
'SELECT * FROM DTSStep_DTSDataPumpTask_2')
In the following example, the package, Sqlpackage, is saved to an instance of Microsoft® SQL Server™ running on your local server. To query the package using SQL Query Analyzer, use the following query statement:
SELECT * FROM OPENROWSET('DTSPackageDSO', '/Usa /P /S /NSqlpackage', 'Select *')
In the OPENROWSET statement:
If you save multiple versions of this package and want to reference a specific version, you need to include the version globally unique identifier (GUID) string after the /V dtsrun command switch. The version GUID can be obtained from the General tab of the DTS Package Properties dialog box. Use the following code to querying a version of the package described above:
SELECT * FROM OPENROWSET('DTSPackageDSO',
'/Usa /P /S /Nsqlpackage /V{3C904BA2-4E83-11D2-BB38-00C04FA35397}',
'Select *')