sqlT-sql远程连接(OPENDATASOURCE)(一)

declare @ServerName nvarchar(600)
declare @Uid nvarchar(60)
declare @Pwd nvarchar(600)
set @ServerName='.'
set @Uid='sa'
set @Pwd='****'


exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

SELECT *
FROM OPENDATASOURCE(
'SQLOLEDB',
'Data Source=&&&&&&;User ID=sa ;password=****'
).MoviesDB.dbo.Movies

exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure

posted @ 2011-07-08 16:03  Shikyoh  阅读(324)  评论(0编辑  收藏  举报