I have two SQL Server databases and I want to reference tables from both DBs
in the SQL. How can I have a connection object that points to both DBs?
Thanks,
T

Re: 2 DBs Ref by 1 DataAdapter? by Jim

Jim
Sun Dec 05 12:12:54 CST 2004

Assuming that they are on the same server, use the three part naming
convention

databasename.owner.tablename

e.g.

select * from northwind.dbo.customers
select * from pubs.dbo.authors

"Tina" <tinamseaburn@removespamexcite.com> wrote in message
news:ui5arHv2EHA.2112@TK2MSFTNGP15.phx.gbl...
>I have two SQL Server databases and I want to reference tables from both
>DBs in the SQL. How can I have a connection object that points to both
>DBs?
> Thanks,
> T
>



Re: 2 DBs Ref by 1 DataAdapter? by Tina

Tina
Sun Dec 05 13:06:04 CST 2004

When using the data adapter wizard, a specific database connection must be
chosen ie. either northwind or pubs and then only tables from that
connection are available in the querybuilder.

I guess my question was "how can this be done using the DataAdapter wizard
and querybuilder.
T

"Jim Hughes" <NOSPAMJ3033@Hotmail.com> wrote in message
news:eQdCMYv2EHA.1296@TK2MSFTNGP10.phx.gbl...
> Assuming that they are on the same server, use the three part naming
> convention
>
> databasename.owner.tablename
>
> e.g.
>
> select * from northwind.dbo.customers
> select * from pubs.dbo.authors
>
> "Tina" <tinamseaburn@removespamexcite.com> wrote in message
> news:ui5arHv2EHA.2112@TK2MSFTNGP15.phx.gbl...
>>I have two SQL Server databases and I want to reference tables from both
>>DBs in the SQL. How can I have a connection object that points to both
>>DBs?
>> Thanks,
>> T
>>
>
>



Re: 2 DBs Ref by 1 DataAdapter? by Chris

Chris
Sun Dec 05 12:49:07 CST 2004

Hi Tina,

If the database servers are on separate machines you can configure a linked
server or use ad hoc distributed queries.. This can be done from within the
Enterprise Manager or you can use the sp_addlinkedserver procedure, for
ad-hoc distributed queries take a look at OPENROWSET.

In both cases you will be setting up a single connection to one server and
the server will manage the connection and retrieval of data from the other
server. For databases on a single server you merely need to prefix the
object name with the database name to query accross databases.

Hope this helps

--
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor


"Tina" <tinamseaburn@removespamexcite.com> wrote in message
news:ui5arHv2EHA.2112@TK2MSFTNGP15.phx.gbl...
> I have two SQL Server databases and I want to reference tables from both
DBs
> in the SQL. How can I have a connection object that points to both DBs?
> Thanks,
> T
>
>