T-SQL跨服務器查詢和插入數據

来源:互联网 发布:当幸福来敲门影评知乎 编辑:程序博客网 时间:2024/06/15 17:13
--解決辦法: 
--使用前: (開啟Ad Hoc Distributed Queries)
exec sp_configure 'show advanced options',1reconfigureexec sp_configure 'Ad Hoc Distributed Queries',1reconfigure




--跨服務器查詢  

--示例 先配置一個服務器連接

EXEC sp_addlinkedserver '服務器的地址',N'SQL Server'

EXEC sp_addlinkedserver '192.168.16.10',N'SQL Server'EXEC sp_addlinkedserver '192.168.16.3',N'SQL Server'-




EXEC sp_addlinkedsrvlogin '192.168.16.10', 'false', NULL, 'sa', 'dba'  --連接到配置的服務器





--跨數據庫插入數據
insert into [192.168.15.10].[ACDATA].[dbo].[PURMB]  select * from [192.168.15.3].[ACDATA].[dbo].[PURMB] where MB01='ET051' --跨服務器查詢  




 
 
原创粉丝点击