OPENQUERY executes the specified direct transfer query on the given linked server (an OLEDB data source. The OPENQUERY function can be referenced in the FROM clause of the query as if the table name was referenced. Based on the capabilities of the OLEDB provider, you can also reference the OPENQUERY function as the target table of the INSERT, UPDATE, or DELETE statement. Check
OPENQUERY executes the specified direct transfer query on the given linked server (an ole db data source. The OPENQUERY function can be referenced in the FROM clause of the query as if the table name was referenced. Based on the capabilities of the ole db provider, you can also reference the OPENQUERY function as the target table of the INSERT, UPDATE, or DELETE statement. Check
OPENQUERY
Execute the specified direct transfer query on the given linked server (an ole db data source. The OPENQUERY function can be referenced in the FROM clause of the query as if the table name was referenced. Based on the capabilities of the ole db provider, you can also reference the OPENQUERY function as the target table of the INSERT, UPDATE, or DELETE statement. Although a query may return multiple result sets, OPENQUERY returns only the first result set.
Syntax
OPENQUERY(Pai_server, 'Query')
Parameters
Pai_server
An identifier, indicating the name of the linked server.
'Query'
The query string executed on the linked server.
Note
OPENQUERY does not accept parameter variables.
Example
The following example uses the Microsoft ole db provider for Oracle to createOracleSvrThe linked server. Then, this example uses a direct transfer query for the linked server.
DescriptionThis example assumes that an Oracle database alias named ORCLDB has been created.
EXEC sp_addlinkedserver 'OracleSvr', 'Oracle 7.3', 'MSDAORA', 'ORCLDB'GOSELECT *FROM OPENQUERY(OracleSvr, 'SELECT name, id FROM joe.titles') GO