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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge 1

Status
Not open for further replies.

scohan

Programmer
Dec 29, 2000
283
US
I need to pull related data from 2 tables, however, the tables are in different databases (SQL server 7, NT 4.0, IIS). Originally, all of the data was pulled from a single table; everything worked well using a vbscript recordset. But now, having to pull an additional column from another table in another database throws a wrench into everything. I can't just join the tables (can I?)

The data is presented on a web page and the user can select any column to sort by that column in ascending or descending order. I'm trying to figure out how to do this. Putting the data in arrays and sorting the array doesn't sound too exciting. Any suggestions? Is there something I can do with a temporary table? Thanks
 
Yes, you can just join them. However, your syntax is a little different.

If your tables are Table1 in DB1, and Table2 in DB2, and you are in DB1, your query would look something like:

SELECT T1.*, T2.Field1
FROM Table1 T1 INNER JOIN [db2].[dbo].[Table1] T2 ON
T1.ID = T2.ID
 
Cool! But what do you mean by [dbo]? I don't keep the brackets, do I?
 
I figured it out. dbo is the db owner. Thanks, it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top