首页
IT
登录
6mi
u
盘
搜
搜 索
IT
SqlServer远程连接
SqlServer远程连接
xiaoxiao
2021-03-25
74
在进行sqlServer远程连接数据库进行查询时前提条件是我们要开启
Ad Hoc Distributed Queries 服务 因为这个服务不安全sqlServer默认关闭该服务
我们需要注意的是在开启服务完成查询后,一定要记得关闭这个服务。
开启 Ad Hoc Distributed Queries :
exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure
关闭:
exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure exec sp_configure 'show advanced options',0 reconfigure
远程查询:
select top 10 * from openrowset ( 'SQLOLEDB','10.122.127.20' ; 'sa';'exp123' ,Expense2BizA.dbo.tblsheet)
关键字指定连接方式 服务器 用户 密码 数据库 表名
--
生成本地表
select
*
into
表
from
openrowset
(
'
SQLOLEDB
'
,
'
sql服务器名
'
;
'
用户名
'
;
'
密码
'
,数据库名.dbo.表名)
--
把本地表导入远程表
insert
openrowset
(
'
SQLOLEDB
'
,
'
sql服务器名
'
;
'
用户名
'
;
'
密码
'
,数据库名.dbo.表名)
select
*
from
本地表
转载请注明原文地址: https://ju.6miu.com/read-9902.html
技术
最新回复
(
0
)