Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data from 2 different DataBases

Status
Not open for further replies.

omauri

Programmer
Jan 24, 2001
12
0
0
CO
Hi. I have 2 different databases. I need the information from the first database to another one. ¿Can I get this information through SQL instruction? Please give me an example. Thanks.
 
You can reference a table in one database while in the context of another database by fully qualifying the table name.

Insert dbname1.dbo.tableA
Select col1, col2, col3, ..., colN
From dbname2.dbo.tableB
Where <your criteria>

You can use the same syntax to create a view in one database that references tables in the other database. The following example shows how to join tables in two databases.

Create View vPartInfo As

Select a.Col1, a.Col2, b.ColX, b.ColY
From database1.dbo.tableA As a
Inner Join database2.dbo.tableB As b
On a.KeyA=b.KeyB Terry L. Broadbent
Programming and Computing Resources
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top