1.配置使用允许跨库查询
EXEC sys.sp_configure N'show advanced options', N'1' RECONFIGURE WITH OVERRIDE
EXEC sys.sp_configure N'Ad Hoc Distributed Queries', N'1'
RECONFIGURE WITH OVERRIDE
2.使用跨库查询
SELECT *
FROM OPENDATASOURCE('SQLNCLI',
'Data Source=zyg;UID=sa;PWD=sasa;')
.gzrs.dbo.AB01