Search this blog

Friday, October 9, 2009

Pass - Through Query In SQL

What is a pass-through query?

Microsoft SQL Server sends pass-through queries as un-interpreted 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'' '

)


2 comments:

  1. Are you sure the first line in red is correct? It seems to me that either the semicolons should be commas OR the apostrophes around those semicolons should be escaped (by back-to-back apostrophes).

    ReplyDelete
  2. most likely, you have also heard about the way of fixing .accdb files

    ReplyDelete