如何连接来自不同数据库但位于两个服务器中的两个表? [英] How to join two tables from different databases but in both server?

查看:96
本文介绍了如何连接来自不同数据库但位于两个服务器中的两个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

向所有程序员问好!

我正在一个从远程桌面访问SQL SERVER 2008-R2数据库中的记录的项目.我在名为Checklist的数据库中有自己的名为tblworkplace的表.我的项目中有一些要求,我需要显示另一个名为Amica的数据库中的tblContractInfo中的记录.我需要加入两个表,以便它仅显示用户想要搜索的内容.但是我不知道如何连接来自不同数据库的两个表.谁能帮我?非常感谢!

Hello to all PROGRAMMERS!

I am working on a project that accessing records in a SQL SERVER 2008-R2 Database from a remote desktop. I have my own table named tblworkplace in a database named Checklist. There are requirements in my project that I need to display the records from tblContractInfo that is on another database named Amica. I need to join the two tables so that it will display only what the user wanted to search for. But I do not know on how to join two tables from different databases. Can anyone help me? Thanks a lot!

推荐答案

从DatabaseA.dbo.TableA中选择a.fldid,a.fldname,a.fldage,b.fldaddress,b.fldjob. DatabaseB.dbo.TableB b a.fldid = b.fldid;

那是我的查询,它很好用!
SELECT a.fldid, a.fldname, a.fldage,b.fldaddress,b.fldjob FROM DatabaseA.dbo.TableA a INNER JOIN DatabaseB.dbo.TableB b ON a.fldid = b.fldid;

That is my query and it works fine!


这篇关于如何连接来自不同数据库但位于两个服务器中的两个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆