Board index » delphi » ADO & Query using multiple databases

ADO & Query using multiple databases

Hi

I am Using ADO and Delphi 5 Pro Sp1 and SQL server v7. Is it possible to do
a select query from 2 tables in 2 different databases with 1 single
sql and how do i do it?

Thanks in advance

Regards

--
Ruaan Barnard
Programmer
CCS Software
Bloemfontein
South Africa
+27 51 4322238
ru...@ccs-software.co.za
www.ccs-software.co.za

 

Re:ADO & Query using multiple databases


Ruaan,

Select
      A.AccountID,
      B.Company
From
   Account.dbo.Accounts A,
   User.dbo.Customer B
Where
   A.AccountID = B.AccountID

Good luck,
krf

Quote
Ruaan Barnard <ru...@nospam.ccs-software.co.za> wrote in message

news:3b83aa41_1@dnews...
Quote
> Hi

> I am Using ADO and Delphi 5 Pro Sp1 and SQL server v7. Is it possible to
do
> a select query from 2 tables in 2 different databases with 1 single
> sql and how do i do it?

> Thanks in advance

> Regards

> --
> Ruaan Barnard
> Programmer
> CCS Software
> Bloemfontein
> South Africa
> +27 51 4322238
> ru...@ccs-software.co.za
> www.ccs-software.co.za

Re:ADO & Query using multiple databases


In article <3b83aa41_1@dnews>, ru...@nospam.ccs-software.co.za says...
Quote
> Hi

> I am Using ADO and Delphi 5 Pro Sp1 and SQL server v7. Is it possible to do
> a select query from 2 tables in 2 different databases with 1 single
> sql and how do i do it?

> Thanks in advance

> Regards

> --
> Ruaan Barnard
> Programmer
> CCS Software
> Bloemfontein
> South Africa
> +27 51 4322238
> ru...@ccs-software.co.za
> www.ccs-software.co.za

Use fully qualified names in your SQL.  (Database.Owner.Table)
Example:

SELECT T1.colA, T1.colB, T2.colC, T2.colD
FROM Database1.dbo.Table1 AS T1 JOIN Database2.dbo.Table2 AS T2
        ON (T1.colE = T2.colF)

Re:ADO & Query using multiple databases


Hi Edwin

Thanks for the example. It was exactly what I was looking for. Thank you
very much.

Regards

Ruaan

Quote
"Edwin Keeton" <ed.kee...@acshome.com> wrote in message

news:MPG.15ed831dee4ecbf3989711@10.1.1.250...
Quote
> In article <3b83aa41_1@dnews>, ru...@nospam.ccs-software.co.za says...
> > Hi

> > I am Using ADO and Delphi 5 Pro Sp1 and SQL server v7. Is it possible to
do
> > a select query from 2 tables in 2 different databases with 1 single
> > sql and how do i do it?

> > Thanks in advance

> > Regards

> > --
> > Ruaan Barnard
> > Programmer
> > CCS Software
> > Bloemfontein
> > South Africa
> > +27 51 4322238
> > ru...@ccs-software.co.za
> > www.ccs-software.co.za

> Use fully qualified names in your SQL.  (Database.Owner.Table)
> Example:

> SELECT T1.colA, T1.colB, T2.colC, T2.colD
> FROM Database1.dbo.Table1 AS T1 JOIN Database2.dbo.Table2 AS T2
> ON (T1.colE = T2.colF)

Other Threads