如何使用SQL Server中的连接从不同服务器的两个不同数据库中选择数据?
问题描述:
我有来自差异服务器的两个差异数据库,
我需要使用连接查询从这些数据库中获取数据..bt我无法获取数据..我的查询是搜索..
I m having two diff databases from diff servers,
and i need to get data from those databases using join query ..bt i ma not able to fetch data..here is my query for search..
AS
declare @Condition as varchar(max)
SET @Condition =''
BEGIN
SET @Condition ='
select
Distinct FollowUpMaster.Followupid,
--EnquiredCourseMaster.Coursecatid,
FollowUpMaster.enqid,
SEnquiryMaster.EnqNo,
SEnquiryMaster.SName,
SEnquiryMaster.EnqDate,
FollowUpMaster.FollowUpMode,
FollowUpMaster.FollowUpDate,
FollowUpMaster.Remarks,
FollowUpMaster.NextFollowUpDate,
(emp.Fname +'' ''+ emp.Mname +'' ''+ emp.Lname) as Counsellor,
emp.Emp_ID,
ERPPROJECT.dbo.FollowUpMaster.FollowUpBy
from
ERPPROJECT.dbo.FollowUpMaster
Inner Join SEnquiryMaster on FollowUpMaster.Enqid=SEnquiryMaster.EnqId
inner join attendance.dbo.Employee_Master as emp on ERPPROJECT.dbo.FollowUpMaster.FollowUpBy=emp.Emp_ID
INNER JOIN EnquiredCourseMaster ON SEnquiryMaster.EnqId=EnquiredCourseMaster.EnqId '
+ '' + @Criteria + ''
print @Condition
exec(@Condition)
END
herer EmployeeMaster是diff数据库中的表..我在同一个数据库中也有相同的命名表,是否会产生冲突?
herer EmployeeMaster is the table from diff database..nd i have also the same named table in same database also ,does it make any conflict ?