Accessing and Changing Relational Data

Using Pass-Through Queries as Tables

Microsoft® SQL Server™ 2000 sends pass-through queries as uninterpreted query strings to an OLE DB data source. The query must be in a syntax the OLE DB data source will accept. A Transact-SQL statement uses the results from a pass-through query as though it is a regular table reference.

This example uses a pass-through query to retrieve a result set from a Microsoft Access version of the Northwind sample database.

SELECT *
FROM OpenRowset('Microsoft.Jet.OLEDB.4.0', 
   'c:\northwind.mdb';'admin'; '', 
   'SELECT CustomerID, CompanyName
         FROM Customers
         WHERE Region = ''WA'' ')

The ways to generate a rowset from an OLE DB provider are:

When a provider supports the Command object, these Transact-SQL functions can be used to send it commands (called pass-through queries):

The OLE DB specification does not define a single command language to be used by all OLE DB providers. OLE DB providers are allowed to support any command language that is related to the data they expose. OLE DB providers that expose the data in relational databases generally support the SQL language. Other types of providers, such as those exposing the data in an e-mail file or network directory, generally support a different language.

See Also

FROM

OPENDATASOURCE

OPENQUERY

OPENROWSET