DTS Designer package data can be made available to an external source, such as SQL Server Query Analyzer, by:
You make package data available by enabling the DSO rowset provider option (on the General tab of the Workflow Properties dialog box) for a package step. The data at that point in the package workflow then becomes available to an external data consumer.
You should only enable the DSO rowset provider option for packages that you intend to query; when the option is set, the package step where you set the option does not complete execution. If you want to set up a package that both executes and serves as a data source, you may need to set up a separate branch in the package workflow to handle external queries.
Note These methods are typically used to query packages from an external source; however, you can also query other packages from within a package by issuing OPENROWSET queries and distributed queries in an Execute SQL task.
You can run queries against a DTS package by using a Transact-SQL OPENROWSET statement.
To ready a package to serve as a data source, enable the DSO rowset provider option (on the General tab of the Workflow Properties dialog box) for a package step.
The following considerations apply to a package that will be queried with OPENROWSET.
For more information on using the Transact-SQL OPENROWSET statement, see OPENROWSET.
Suppose you want to use SQL Server Query Analyzer to query a package saved to the Data Transformation Services file Dso.dts on your local server. The query statement would look something like:
SELECT * FROM OPENROWSET('DTSPackageDSO', '/FC:\Dts\Dso.dts', 'Select *')
In the OPENROWSET statement:
If you had enabled more than one DSO rowset provider option setting in the above package, the following statement uses OPENROWSET to query the second package step in Dso.dts:
SELECT * FROM OPENROWSET('DTSPackageDSO', '/FC:\Dts\Dso.dts',
'SELECT * FROM DTSStep_DTSDataPumpTask_2')
Suppose you want to use SQL Server Query Analyzer to query the Microsoft SQL Server™ package Sqlpackage on your local server. The query statement would look something like:
SELECT * FROM OPENROWSET('DTSPackageDSO', '/Usa /P /S /NSqlpackage', 'Select *')
In the OPENROWSET statement:
If you had saved multiple versions of this package and wanted to reference a specific version, you would need to include the version 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). Querying a version of the package described above would look something like:
SELECT * FROM OPENROWSET('DTSPackageDSO',
'/Usa /P /S /Nsqlpackage /V{3C904BA2-4E83-11D2-BB38-00C04FA35397}',
'Select *')
You can also register a package as a linked server and issue a distributed query against the package. To do so, you need to define the package as a linked server through the sp_addlinkedserver stored procedure. This is an example of using sp_addlinkedserver against a DTS package:
sp_addlinkedserver 'DTSOLEDBPkg', 'PackageName', 'DTSPackageDSO', '/FC:\Dts\Dts01.dts')
In the sp_addlinkedserver command:
After you have defined the package as a linked server, you can execute distributed queries that include the package as a data source. Following is an example of a distributed query. It performs a join operation on the Orders table in the Northwind database with a package that gets data from a Customer table on an Oracle server. The query assumes the Orders and Customers tables have a common key, which is CustomerID.
SELECT a.OrderID, a.CustomerID, a.OrderDate, b.Companyname, b.Region
FROM Orders AS a, dtsLink...packageNameOracle AS b
WHERE a.CustomerID = b.CustomerID
In the above query, packageNameOracle is the DTS package name; however, a package step name can be used instead. You would want to use a package step name when multiple steps in a package serve as data sources.