Unix Technical Forum

Query on 2 bases

This is a discussion on Query on 2 bases within the SQL Server forums, part of the Microsoft SQL Server category; --> How to make a query which contains fields from two different bases ? Thanks in advance. ReN...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:16 PM
TNR
 
Posts: n/a
Default Query on 2 bases

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

Thanks in advance.

ReN


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 06:16 PM
John Bell
 
Posts: n/a
Default Re: Query on 2 bases

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

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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 06:17 PM
Tony Hodgson
 
Posts: n/a
Default Re: Query on 2 bases

"John Bell" <jbellnewsposts@hotmail.com> wrote in message news:<3f252ad9$0$18494$ed9e5944@reading.news.pipex .net>...
> This request was posted earlier today under the title "Inter-Database
> References"
>
> John
> "TNR" <stage7@tgs.fr> wrote in message
> news:bg38re$u6c$1@news-reader5.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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:52 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com