Link to home
Start Free TrialLog in
Avatar of AZZA-KHAMEES
AZZA-KHAMEESFlag for Bahrain

asked on

Get Result from two diffrent databse

Hello Expert, i am trying to writ an sql statment that retrieve a data from two defrrent databse depend on a condition, will actully can i do this in sql??
i have a table that contain a user id i want to get the full name either from db1.table1 or db2.table1 my sql statement is

SELECT     dbo.tblCallDetail.UserId, dbo.tblMinisUser.FullName, pr1.dbo.GetUserDetailsE.EngName
FROM        
dbo.tblCallDetail INNER JOIN  
dbo.tblMinisUser ON dbo.tblCallDetail.UserId = dbo.tblMinisUser.UserId
AND
dbo.tblCallDetail.UserId = dbo.tblMinisUser.UserId INNER JOIN
pr1.dbo.GetUserDetailsE ON dbo.tblCallDetail.UserId = pr1.dbo.GetUserDetailsE.PERUserName AND
dbo.tblCallDetail.UserId = pr1.dbo.GetUserDetailsE.PERUserName

but its wrong sql how can i correct the sql?
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AZZA-KHAMEES

ASKER

its working but can i show the fields mu.FullName, gud.EngName in one field called FullUserName ??
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you :)