zoukankan      html  css  js  c++  java
  • OPENQUERY (Transact-SQL)

    Syntax

    
    OPENQUERY ( linked_server ,'query' )  
    

    Arguments

    linked_server
    Is an identifier representing the name of the linked server.

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

    Remarks

    OPENQUERY does not accept variables for its arguments.

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

    EXEC SeattleSales.master.dbo.xp_msver  
    

    Any call to OPENDATASOURCE, OPENQUERY, or OPENROWSET in the FROM clause is evaluated separately and independently from any call to these functions used as the target of the update, even if identical arguments are supplied to the two calls. In particular, filter or join conditions applied on the result of one of those calls have no effect on the results of the other.

    Permissions

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

    Examples

    A. Executing an UPDATE pass-through query

    The following example uses a pass-through UPDATE query against the linked server created in example A.

    UPDATE OPENQUERY (OracleSvr, 'SELECT name FROM joe.titles WHERE id = 101')   
    SET name = 'ADifferentName';  
    

    B. Executing an INSERT pass-through query

    The following example uses a pass-through INSERT query against 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 pass-through DELETE query to delete the row inserted in example C.

    DELETE OPENQUERY (OracleSvr, 'SELECT name FROM joe.titles WHERE name = ''NewTitle''');  
  • 相关阅读:
    换装WIN10(windows)那点儿事,换装操作系统一文通,玩转安装操作系统
    Win10永久版低价购买及激活工具使用说明
    Win10系统自带软件删除和恢复工具
    微软免费AI作文打分软件升级:雅思考研四六级都能用,还能查单词给替换
    扫描全能王 v5.13.0.20190916 去水印和广告版
    Vue组件
    vue自定义过滤器的创建和使用
    vue自定义指令的创建和使用
    vue的基础使用
    vue的概述
  • 原文地址:https://www.cnblogs.com/Javi/p/7240399.html
Copyright © 2011-2022 走看看