sqlexpress
Using INNER JOIN across different databases
Thread Starter: Raimundo Alba Started: 11/14/2008 11:55 AM UTC
Replies: 4
Using INNER JOIN across different databases
Hello to all,

Just a new user starting to migrate apps to Sql way with wonderful SQLEXPRESS... :)

Could anyone point us if possible to use INNER JOIN sentences across different databases to get a dataset... and a little example.

Many thanks in advance.
Raimon
Re: Using INNER JOIN across different databases
"Raimundo Alba" <raimon@fersoft.es> wrote in news:75136783$625dde4b$3016
@news.xbwin.com:

Just a new user starting to migrate apps to Sql way with wonderful SQLEXPRESS... :)
Could anyone point us if possible to use INNER JOIN sentences across different databases to get a dataset... and a little example.

In SQL Server a select statement takes the following form:

SELECT [C1],[C2],[C3],[C4]
 FROM [ACME].[dbo].[SOMETABLE]

where [ACME] is the database name, [dbo] is the user id, [SOMETABLE] is the table name.

I have not tried it, but I'm pretty sure you can create a join like this:

SELECT c.name, i.date, i.amt FROM db1.dbo.customer c, db2.dbo.invoice i
WHERE c.id=i.custid and i.amt_os > 0

-- Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools
Re: Using INNER JOIN across different databases
Thanks for the hint, going to try and report...
 
Raimon
 
"Boris Borzic" <support-at-xb2-dot-net> escribió en el mensaje news:Xns9B565E50C62F0SQLExpress@68.178.173.112...
"Raimundo Alba" <raimon@fersoft.es> wrote in news:75136783$625dde4b$3016
@news.xbwin.com:

> Just a new user starting to migrate apps to Sql way with wonderful
> SQLEXPRESS... :)
>
> Could anyone point us if possible to use INNER JOIN sentences across
> different databases to get a dataset... and a little example.

In SQL Server a select statement takes the following form:

SELECT [C1],[C2],[C3],[C4]
  FROM [ACME].[dbo].[SOMETABLE]

where [ACME] is the database name, [dbo] is the user id, [SOMETABLE] is the
table name.

I have not tried it, but I'm pretty sure you can create a join like this:

SELECT c.name, i.date, i.amt
FROM db1.dbo.customer c, db2.dbo.invoice i
WHERE c.id=i.custid and i.amt_os > 0

--
Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools
Re: Using INNER JOIN across different databases
Hello Boris,
 
Sample working following your guidelines... now:
 
SELECT c.name, i.date, i.amt
FROM db1.dbo.customer c, db2.dbo.invoice i
WHERE c.id=i.custid and i.amt_os > 0
 
Is there any way to make an statement or something so to combine data from two different databases that reside in two different SQL Server machines?
Sample you showed works well joining where db1 and db2 databases are stored in the same Server but we need to make the same from two different servers.
 
Best Regards.
Raimundo Alba
 
 
"Raimundo Alba" <raimon@fersoft.es> escribió en el mensaje news:6bdaa94c$6335cada$17e6@news.xbwin.com...
Thanks for the hint, going to try and report...
 
Raimon
 
"Boris Borzic" <support-at-xb2-dot-net> escribió en el mensaje news:Xns9B565E50C62F0SQLExpress@68.178.173.112...
"Raimundo Alba" <raimon@fersoft.es> wrote in news:75136783$625dde4b$3016
@news.xbwin.com:

> Just a new user starting to migrate apps to Sql way with wonderful
> SQLEXPRESS... :)
>
> Could anyone point us if possible to use INNER JOIN sentences across
> different databases to get a dataset... and a little example.

In SQL Server a select statement takes the following form:

SELECT [C1],[C2],[C3],[C4]
  FROM [ACME].[dbo].[SOMETABLE]

where [ACME] is the database name, [dbo] is the user id, [SOMETABLE] is the
table name.

I have not tried it, but I'm pretty sure you can create a join like this:

SELECT c.name, i.date, i.amt
FROM db1.dbo.customer c, db2.dbo.invoice i
WHERE c.id=i.custid and i.amt_os > 0

--
Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools
Re: Using INNER JOIN across different databases
"Raimundo Alba" <raimon@fersoft.es> wrote in
news:6005af14$5c5837be$5497@news.xbwin.com:  

Sample working following your guidelines... now:
SELECT c.name, i.date, i.amt FROM db1.dbo.customer c, db2.dbo.invoice i
WHERE c.id=i.custid and i.amt_os > 0
Is there any way to make an statement or something so to combine data
from two different databases that reside in two different SQL Server
machines? Sample you showed works well joining where db1 and db2
databases are stored in the same Server but we need to make the same
from two different servers.  

Here's some online info that may help:
http://msdn.microsoft.com/en-us/library/aa172738(SQL.80).aspx

-- Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools

   Links to product home pages:   • SQLExpress - Xb2.NET     • ot4xb