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

Column needed from another database 1

Status
Not open for further replies.

charbrad

Technical User
Nov 7, 2002
132
US
I have two databases database1 & database2. I can retrieve most of my information from a table in database1, but there is a column from a table in database2 that I need to complete my query. Is there a way to join this column from database2 to my ouput from data retrieved from database1?
 
SQL2005??? If so, try:

JOIN servername.databasename.schemaname.tablename d2 ON d1table.idcolumn = d2.idcolumn

and in the SELECT portion of your query:

d2.columnname

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Haven't done any 2000 in a while, but should be something like if on the same server (notice the two dots....dbo implication for sql2000 if I remember correctly):

JOIN databasename..tablename d2 ON d1table.idcolumn = d2.idcolumn

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top