dbTalk Databases Forums  

Query on 2 bases

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Query on 2 bases in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
TNR
 
Posts: n/a

Default Query on 2 bases - 07-28-2003 , 08:31 AM






How to make a query which contains fields from two different bases ?

Thanks in advance.

ReN



Reply With Quote
  #2  
Old   
John Bell
 
Posts: n/a

Default Re: Query on 2 bases - 07-28-2003 , 08:51 AM






This request was posted earlier today under the title "Inter-Database
References"

John
"TNR" <stage7 (AT) tgs (DOT) fr> wrote

Quote:
How to make a query which contains fields from two different bases ?

Thanks in advance.

ReN





Reply With Quote
  #3  
Old   
Tony Hodgson
 
Posts: n/a

Default Re: Query on 2 bases - 07-29-2003 , 10:53 AM



"John Bell" <jbellnewsposts (AT) hotmail (DOT) com> wrote

Quote:
This request was posted earlier today under the title "Inter-Database
References"

John
"TNR" <stage7 (AT) tgs (DOT) fr> wrote in message
news:bg38re$u6c$1 (AT) news-reader5 (DOT) wanadoo.fr...
How to make a query which contains fields from two different bases ?

Thanks in advance.

ReN


If your databases are on the same server then it's as simple as:

select *
from database1..table1 inner join database2..table2

if they are on different servers, then you'll need to add a linked
server to the database that you are running your query on. This can
be done through the GUI or by running sp_addlinkedserver system stored
procedure. Once you've done it then, the command is:

select *
from database1..table1 inner join linkedservername.database2..table2

Hope this helps
Hodge


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.