Results 1 to 5 of 5

Thread: How to connect to multiple Database to query from each

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    How to connect to multiple Database to query from each

    I have two databases in a same sever of MS SQL Server 2005. Now I want to make query from tables of each database. How can I do this ? and how will connect to both databases at time to peform query in tables of both using UNION clause.

    Nasreen

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: How to connect to multiple Database to query from each

    Something like:

    select top 1 * from Database..Table T1
    join database..table T2 on T1.Key = T2.Key

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to connect to multiple Database to query from each

    Thread moved to 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    105

    Re: How to connect to multiple Database to query from each

    Quote Originally Posted by TysonLPrice View Post
    Something like:

    select top 1 * from Database..Table T1
    join database..table T2 on T1.Key = T2.Key
    My problem is not in select query statement, but it is connection string. Can you please tell how the above query is run using Vb ADOBD Connection and ADODB recordset ?. What connection you may use to run this query ?

    Nasreen

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to connect to multiple Database to query from each

    The connection string can only connect to one database.

    As TysonLPrice used the fully qualified name for both databases, it does not matter which one you connect to - you just run the query in the usual way.


    The problems you might get are based around the permissions within the database... if that happens, tell us the details of the problem.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width