Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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..
SQL
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 is the table from diff database..nd i have also the same named table in same database also ,does it make any conflict ?
Posted
Comments
King Fisher 3-Feb-14 6:50am    
any error?

1 solution

 
Share this answer
 
Comments
rahulDer 3-Feb-14 6:31am    
not useful still..
Ahmed Bensaid 3-Feb-14 6:33am    
Why ?
rahulDer 3-Feb-14 6:34am    
i have also tried with sp_addlinkedserver but not worked..
Ahmed Bensaid 3-Feb-14 6:38am    
I think you have to investigate why this solution doesn't work ...
rahulDer 3-Feb-14 6:44am    
is there any other way to deal with this ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900