当前位置:网站首页>跨服务器数据访问的创建链接服务器方法
跨服务器数据访问的创建链接服务器方法
2022-07-02 10:59:00 【迪丽热爱】
SQL数据库创建链接服务,不止在SQL数据库,也可以Oracle其他,本文针对于SQL的操作说明
1.对跨服务器进行临时访问,直接用 OPENROWSET的方式
--查询语句范例
--select top 1 *from openrowset('SQLOLEDB','服务名';'账号';'密码',数据库.dbo.表)a
select top 1 *
from openrowset('SQLOLEDB','192.168.1.1';'sa';'111',TEST.dbo.TEST)a
where NO ='1'本查询的时候时候会提示错误“提示:SQL Server 阻止了对组件'Ad Hoc Distributed Queries '的STATEMENT 'OpenRowset/OpenDatasource'”,请参考下一篇博文的针对性说明的解决办法。
2.跨服务器数据访问,创建链接服务器
2.1 语句创建
--跨服务器数据访问
--如果经常访问或数据量大,建议用链接服务器
--创建链接服务器
--创建范例如下
--SQLOLEDB 默认为SQL数据库
--SER_REMOTEERP 为你取得服务名,可以写192.168.1.2 也可以任意取其他
-------------------------------------------------------------------
--创建语句
EXEC sp_addlinkedserver 'SER_REMOTEERP','','SQLOLEDB','192.168.1.2'
--本地用户名,远程服务登入名,远程服务的密码
--一般创建用 null 或SA
EXEC sp_addlinkedsrvlogin 'SER_REMOTEERP','false',null,'sa','密码'
EXEC sp_serveroption 'SER_REMOTEERP','rpc out','true'
--查询语句
select top 1 * from SER_REMOTEERP.数据库名.dbo.表名
--删除链接服务
EXEC sp_dropserver 'SER_REMOTEERP','droplogins'如果创建时候遇到问题:没有从远程服务器‘‘映射到本地用户‘(null)/sa‘的远程用户‘sa‘及服务主密码解密错误”,则参考我的下一篇博文进行解决,连接如下
没有从远程服务器‘‘映射到本地用户‘(null)/sa‘的远程用户‘sa‘及服务主密码解密错误的解决办法_迪丽热爱的博客-CSDN博客
2.2 SQL画面操作

输入远程登入的账号和密码

RFC和RFC OUT 选择TRUE

测试连接进行验证

边栏推荐
猜你喜欢

Mysql5.7 installation super easy tutorial

Simple introduction to ENSP
[document tree, setting] font becomes smaller

每日学习3

Use bloc to build a page instance of shutter

Teamtalk source code analysis win client

Selenium element positioning method

Everyone believes that the one-stop credit platform makes the credit scenario "useful"
![[Hongke technology sharing] how to test DNS server: DNS performance and response time test](/img/f4/d8c21d6c33985fd6d819cd44c22c72.png)
[Hongke technology sharing] how to test DNS server: DNS performance and response time test

Packet capturing tool Fiddler learning
随机推荐
P3008 [USACO11JAN]Roads and Planes G (SPFA + SLF优化)
In 2021, the global revenue of structural bolts was about $796.4 million, and it is expected to reach $1097.6 million in 2028
腾讯云 TStor 统一存储通过信通院首批文件存储基础能力评测
Dingtalk 发送消息
Qt原代码基本知识
Launcher启动过程
Code implementation MNLM
每日学习3
Mysql5.7 installation super easy tutorial
Multi rotor aircraft control using PID and LQR controllers
Adhere to the foundation of 20 minutes go every day II
Data consistency between redis and database
万物生长大会在杭召开,当贝入选2022中国未来独角兽TOP100榜单
Codeforces Round #803 (Div. 2)(A~D)
<口算练习机 方案开发原理图>口算练习机/口算宝/儿童数学宝/儿童计算器 LCD液晶显示驱动IC-VK1621B,提供技术支持
默认插槽,具名插槽,作用域插槽
Pattern matching and regular expressions in PostgreSQL - Das
The most complete analysis of Flink frame window function
693. 行程排序(map + 拓扑)
故事點 vs. 人天