473,387 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

LInk two tables from two databases

112 100+
Hi,
I have two different databases in our company for diffrent departments. for some reason i need to connect few tables to another database.So i created tables in the other database which i need to link. If anybody know to link the table i m very greatful.
Thanks
imt
Jan 10 '07 #1
7 27513
almaz
168 Expert 100+
Hi,
I have two different databases in our company for diffrent departments. for some reason i need to connect few tables to another database.So i created tables in the other database which i need to link. If anybody know to link the table i m very greatful.
Thanks
imt
Are these databases reside on the same SQL Server? If yes, than you don't have to "link" tables, just use them :). For example, you have a table1 in database1 and you want to join it to table2 in database2. Than you can use the following script:
Expand|Select|Wrap|Line Numbers
  1. select * 
  2. from table1 t1 inner join database2..table2 t2 on t1.ID = t2.ID
Jan 10 '07 #2
iburyak
1,017 Expert 512MB
Just in case two servers are not linked to each other but you still have access to another server you can try query below:

[PHP]select *
from table1 t1
inner join OPENDATASOURCE(
'SQLOLEDB',
'Data Source=server_name;User ID=UserID;Password=password'
).database_name.dbo.table2 t2 on t1.ID = t2.ID[/PHP]
Jan 10 '07 #3
imtmub
112 100+
Just in case two servers are not linked to each other but you still have access to another server you can try query below:

[PHP]select *
from table1 t1
inner join OPENDATASOURCE(
'SQLOLEDB',
'Data Source=server_name;User ID=UserID;Password=password'
).database_name.dbo.table2 t2 on t1.ID = t2.ID[/PHP]
Thanks i have two diffrent server, i hope the second one will work.
Jan 11 '07 #4
almaz
168 Expert 100+
Thanks i have two diffrent server, i hope the second one will work.
If you want to link servers on a permanent basis, see linked servers
Jan 11 '07 #5
imtmub
112 100+
If you want to link servers on a permanent basis, see linked servers
Hi,
in my tables t1.ID = t2.ID is not matching. bcz t2.id is new table. if anybody enter the data in table 1 in real time need to copy in table2. Not all the fields but few fields i need to copy.

Thanks
imt
Feb 7 '07 #6
iburyak
1,017 Expert 512MB
If you want to link servers on a permanent basis, see linked servers
By the way for security and other reasons it is not allowed to link servers in my company.
Feb 7 '07 #7
It works only when you refer table1 as database1..table1
Jun 24 '14 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: James Robinson | last post by:
We have multiple databases created with forms in them. I want to create a master form that can link to any of the other database forms. If you have all of the tables and forms, ect., in one...
18
by: Bruce Lawrence | last post by:
We use Access 97. We are in the process of migrating to 2003 along with SQL in most cases. We have a production database that contains a pretty important table and we would like to know which...
7
by: Lisa | last post by:
I have an Access 2000 application that uses the following function to re-link my tables when I switch from my Current back end to a Dummy back end. I also use it to refresh my links. Function...
13
by: rdemyan via AccessMonster.com | last post by:
My front-end code manually links to the backend file. I was wondering what stops Access from linking to the system tables in the backend file. Is it just by virtue that they are hidden? This...
4
by: Tracey | last post by:
I have a Mysql database hosted on a remote server. Previously, I could always connect to those databases using the 3.51 ODBC connector and linking the tables in Access. The benefit of this is that...
26
by: Troyerrm | last post by:
I tried posting this but got an error the first time. I have set up SQL server on an XP Pro laptop and transferred 2 databases from another laptop which was sucessfull. I also transferred an...
7
by: ApexData | last post by:
Hello I currently Link the FE/BE using the LinkTables Option and the Linked Table Manager. Any time I need to move the BE to another location, I have to go through this process over again. I...
2
by: holdingbe | last post by:
Hi, I get very difficult requirement from my friend. I explain clearly below : I have two databases. Source databases: Flower |__________schema: sample. ...
8
by: Neil | last post by:
I just started using Access 2003, and I can't link a SQL Server table. I right-click on the database window; select Link Tables; and select ODBC Databases from the Files of Type dropdown. As soon...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.