SQL Server remote access to Oracle database

Source: Internet
Author: User
Tags ole

After you create a new connection server on SQL Server

Executes the specified pass-through query on the specified linked server.The server is an OLE DB data source.OPENQUERY can be referenced in the FROM clause of a query as if it were a table name. OPENQUERY can also be referenced as the target table for an INSERT, UPDATE, or DELETE statement. However, this depends on the functionality of the OLE DB access interface. Although the query may return more than one result set, OPENQUERY returns only the first one.

Transact-SQL syntax Conventions

Grammar Copy
OPENQUERY (linked_server, ' query ')
Parameters
Linked_server

Represents the identifier for the linked server name.

' query '

The query string executed in the linked server. the maximum length of the string is 8 KB.

Notes

OPENQUERY A variable that does not accept its arguments.

OPENQUERY cannot be used to perform extended stored procedures on linked servers. However, you can execute an extended stored procedure on a linked server by using the four-part name. For example:

EXEC SeattleSales.master.dbo.xp_msver

Any call to OpenDataSource, OPENQUERY, or OPENROWSET in the FROM clause is calculated separately from any calls to those functions that are used as the update target, even if the same arguments are supplied for the two calls. specifically, filters or join conditions that apply to the results of any of these calls do not affect the results of other calls.

Permissions

Any user can execute OPENQUERY. The permissions used to connect to the remote server are obtained from the settings defined for the linked server.

Example A. Executing an UPDATE pass-through query

The following example uses the UPDATE delivery query for the linked server created in example A .

UPDATE OPENQUERY (oraclesvr, ' SELECT name from joe.titles WHERE id = 101 ') SET name = ' Adifferentname ';
B. Performing an INSERT pass-through query

The following example uses the INSERT pass-through query for the linked server created in example A .

INSERT OPENQUERY (oraclesvr, ' SELECT name from Joe.titles ') VALUES (' Newtitle ');
C. Executing a DELETE pass-through query

The following example uses a delete pass query to delete rows inserted in example C.

DELETE OPENQUERY (oraclesvr, ' SELECT name ' from joe.titles WHERE name = ' Newtitle ');

SQL Server remote access to Oracle database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.