• sql2005,sql2000 跨局域网操作 OPENDATASOURCE


    sql2005跨服务器查询的语句_百度知道  

    2009-06-02 14:20:57|  分类: 默认分类 |  标签: |字号 订阅

     
     
    --在查询分析器中,在mt-ap-09服务器中创建链接服务器
    exec sp_addlinkedserver  'srv_lnk','','SQLOLEDB','mt-ap-07'
    exec sp_addlinkedsrvlogin 'srv_lnk','false',null,'用户名','密码'
    go
    
    --在查询分析器中,建立sp
    create proc pro_test
    as
    select name from HRDB.dbo.people a
    inner join srv_lnk.MainDB.dbo.cabinet b on a.name=b.name
    where b.flag=1 
    go
    
    --按纽的代码写入如下(执行sp)
    exec pro_test 
    2000下面可以直接这样查询
    select * from OPENDATASOURCE( 'SQLOLEDB', 'Data Source=远程ip;User ID=sa;Password=密码' ).库名.dbo.表名

     ---------------------------------------------------------------------------------------------------------------
     
    AD HOC好像是一个Ad Hoc网络,
    
    英文不好呵,好像是注册AD HOC网络所在的地区什么的。

    下面是网上找到的:
    SQL Server 阻止了对组件 \'Ad Hoc Distributed Queries\' 的访问2009-12-29 10:50在Sql Server中查询一下Excel文件的时候出现问题:
    SELECT * FROM OPENROWSET( 'MICROSOFT.JET.OLEDB.4.0','Excel8.0;IMEX=1;HDR=YES;DATABASE=D:\a.xls',[sheet1$])
    结果提示:
    SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。有关启用 'Ad Hoc Distributed Queries' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。


    查询相关资料,找到解决方法:
    启用Ad Hoc Distributed Queries:
    exec sp_configure 'show advanced options',1
    reconfigure
    exec sp_configure 'Ad Hoc Distributed Queries',1
    reconfigure
    使用完成后,关闭Ad Hoc Distributed Queries:
    exec sp_configure 'Ad Hoc Distributed Queries',0
    reconfigure
    exec sp_configure 'show advanced options',0
    reconfigure

    因此我猜测是要你注册自己在该网络上。
  • 相关阅读:
    Medium | LeetCode 347. 前 K 个高频元素 | 快速排序
    Medium | LeetCode 215. 数组中的第K个最大元素 | 快速排序
    Easy | LeetCode 75. 颜色分类 | 快速排序
    lib和dll
    windows使用cmd打印出当前路径下的所有文件名称
    windows中的sleep和Ubuntu中的sleep
    ‘mutex’ in namespace ‘std’ does not name a type
    gcc命令参数
    ubuntu18.04 使用pthread库
    vs2019 c语言配置pthreads多线程
  • 原文地址:https://www.cnblogs.com/wuyifu/p/2875076.html
Copyright © 2020-2023  润新知