Home > Archive > MS SQL Server > January 2006 > Data access from multiple DBs









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Data access from multiple DBs
Kay

2006-01-31, 11:23 am

dear all,
I want to execute this statment

Select db1.dbo.table1.column1, db2.dbo.table2.column2
from db1.table1 inner join db2.table2
on db1.dbo.table1.column1= db2.dbo.table2.column1

since i am using to different DBs to fetch resultset. What should I do to
accomplish this task. One way is to declare linked server by
sp_addlinkedserver. What are the pros and cons of defining linked server?

Is there some other way to do so which is better comparing to linked server
approach?

TIA
Kay


Jens

2006-01-31, 11:23 am

You are not using a linked server, as from your query you are only
using the local server that you are connected to, the linked server
scenario goes with the four part notation, you are just using the three
part one (beside the column identifier), a better more easy writing
would be to use aliases like:

Select t1.column1, t2.column2
from db1.table1 t1
inner join db2.table2 t2 on
t1.column1= t2.column1

HTH, Jens Suessmeyer.

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com