Re: How do I read records from databases in two different connections ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Aaron Bertrand [MVP] (aaron_at_TRASHaspfaq.com)
Date: 04/02/04


Date: Fri, 2 Apr 2004 18:38:35 -0500

If the two databases are on the same server, use one connection. e.g. if
you use cn1, then

sql = "SELECT column1, column2 FROM tablename t1 RIGHT JOIN
db2.dbo.tablename t2 ON t1.column1 = t2.column1"

(Note you will want to check your syntax, I spot at least a few errors
there.)

-- 
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
<CobraStrikes@al.com> wrote in message 
news:c4kqtf$rcf$1@news8.svr.pol.co.uk...
> Hi I will be most grateful if any one can help me.
> I have 2 connections to two different databases.
> cn1 has database db1
> cn2 has database db2
>
> SQL = "SELECT field1,field2 FROM (db1 right join db2 on 
> db1.field1=db2.field1)"
>
> I get an exception error, I think it is because I am using two 
> connections.
> Can anyone tell me how to build the string ???
> hope I explained well enough ?????
> TIA
>
>
> 


Relevant Pages

  • Re: T-SQL
    ... connections to two different databases. ... A stored procedure runs on one connection, ... multiple databases on the same instance of SQL Server. ...
    (comp.databases.ms-sqlserver)
  • Unable to log into the database
    ... I am trying to connect to a database on a server on our network. ... two databases one is Interbase, ... I can open the connections in the server explorer connect ...
    (microsoft.public.vb.database)
  • Unable to log into the database
    ... I am trying to connect to a database on a server on our network. ... two databases one is Interbase, ... I can open the connections in the server explorer connect ...
    (microsoft.public.vb.database.ado)
  • RE: Q: Named pipes and Windows (integrated) authentication
    ... Trusted Connections or Windows Authentication is when the client uses ... A user needs first to be able to authenticate to the server either using: ... Creating databases is only acomplished after you've already connected. ...
    (microsoft.public.sqlserver.connect)
  • Re: AS2005 ... what is wrong with it?
    ... What I have seen is that the dev server is *faster* than the prod server ... And does your dev server also have all 6 databases with all these roles? ... When I restore the "PROV" i got approx 20 sec. ... Starting from an empty data folder should show if this theory is true ...
    (microsoft.public.sqlserver.olap)