同一个服务器不同数据库的表连接

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

select * from JudgeProblem b inner join
opendatasource('SQLOLEDB','Data Source=.;user ID=sa;password=sa;').Hxkr_kc_null.dbo.Site a
on a.SiteID=b.CourseID
go

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

posted @ 2013-06-16 10:40  牡丹  阅读(266)  评论(0编辑  收藏  举报