夸服务器操作数据库

--打开
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 * From OPENDATASOURCE('SQLOLEDB','Data Source=192.168.82.68;User ID=sa;Password=123456').[NWEPDI.EPDS].dbo.EventDefine
SELECT name FROM OPENDATASOURCE('SQLOLEDB','Data Source=192.168.82.68;User ID=sa;Password=123456').[NWEPDI.EPDS].[SYS].[OBJECTS]
where TYPE = 'U'


--方法二
--创建链接服务器
exec sp_addlinkedserver 'ITSV ', ' ', 'SQLOLEDB ', '192.168.82.68'
exec sp_addlinkedsrvlogin 'ITSV ', 'false ',null, 'sa', '123'
select TOP(10) * from ITSV.EPDS.dbo.EventDefine

posted on 2013-06-14 15:57  larryle  阅读(184)  评论(0编辑  收藏  举报