sql跨数据库查询
数据库1:AAA
数据库2:BBB
数据库名和表名之间放两个点
select*from[AAA]..TableAainnerjoin[BBB]..TableBbona.AcountID=b.ClientID
或者
SELECT uf.UDFVCSD2,D.DeptCode,D.Leader FROM SHAT_App.dbo.UserDefinedFields uf left join SHATDB.dbo.Dept D on D.DeptCode=uf.UDFVCSD2
where UDFVCSD2 IS NOT NULL
SELECT uf.UDFVCSD2,D.DeptCode,D.Leader FROM SHAT_App.dbo.UserDefinedFields uf left join SHATDB.dbo.Dept D on D.DeptCode=uf.UDFVCSD2
where UDFVCSD2 IS NOT NULL
注意:必须是单个Sql实例!