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

你可能感兴趣的:(dataSource)