zoukankan      html  css  js  c++  java
  • sqlserver跨数据库查询数据

    --一、操作提权
    /*
    --启用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
    */
    
    declare @A varchar(100)=null;
    declare @B varchar(100)=null;
    
    --查询本地库数据信息
    select top 1 @A =sum(NowNum)  from table1
    
    --启动远程服务器连接,添加一次就可以
    --EXEC sp_addlinkedserver '服务器地址',N'SQL Server'        --将远端数据库映射到本地数据
    --EXEC sp_addlinkedsrvlogin '服务器地址', 'false', NULL, '数据库账号', '密码'  -- 启动链接远端服务器 
    
    --二、跨数据库查询数据
    select top 1  @B= sum(NowNum) from [服务器地址].数据库名.dbo.[表名]
  • 相关阅读:
    golang单例模式
    PHP打开并修改文件
    关于文件服设计的一些想法
    Api
    golang Iterate through the fields of a struct in Go
    zookeeper note
    centos 6 install protoc
    todo
    linux route
    build http_load
  • 原文地址:https://www.cnblogs.com/damugua/p/15435156.html
Copyright © 2011-2022 走看看