Query on 2 bases

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TNR

    Query on 2 bases

    How to make a query which contains fields from two different bases ?

    Thanks in advance.

    ReN


  • John Bell

    #2
    Re: Query on 2 bases

    This request was posted earlier today under the title "Inter-Database
    References"

    John
    "TNR" <stage7@tgs.f r> wrote in message
    news:bg38re$u6c $1@news-reader5.wanadoo .fr...[color=blue]
    > How to make a query which contains fields from two different bases ?
    >
    > Thanks in advance.
    >
    > ReN
    >
    >[/color]


    Comment

    • Tony Hodgson

      #3
      Re: Query on 2 bases

      "John Bell" <jbellnewsposts @hotmail.com> wrote in message news:<3f252ad9$ 0$18494$ed9e594 4@reading.news. pipex.net>...[color=blue]
      > This request was posted earlier today under the title "Inter-Database
      > References"
      >
      > John
      > "TNR" <stage7@tgs.f r> wrote in message
      > news:bg38re$u6c $1@news-reader5.wanadoo .fr...[color=green]
      > > How to make a query which contains fields from two different bases ?
      > >
      > > Thanks in advance.
      > >
      > > ReN
      > >
      > >[/color][/color]

      If your databases are on the same server then it's as simple as:

      select *
      from database1..tabl e1 inner join database2..tabl e2

      if they are on different servers, then you'll need to add a linked
      server to the database that you are running your query on. This can
      be done through the GUI or by running sp_addlinkedser ver system stored
      procedure. Once you've done it then, the command is:

      select *
      from database1..tabl e1 inner join linkedservernam e.database2..ta ble2

      Hope this helps
      Hodge

      Comment

      Working...