Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123

    Unanswered: Consoldating data across databases

    Thanks in advance for your help,

    Is there an easy way to "link" data from one SQL database to another, preferably within a view?

    More specifically, can one "link" to data from 2 seperate databases to a 3rd without importing the data?

    Thanks,
    Lee

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Sure, if they are on the same server then just use 3-part naming convention in your queries:

    select t1.f2, t2.f2, t3.f2
    from db1.dbo.t t1
    inner join db2.dbo.t t2 on t1.f1=t2.f1
    inner join db3.dbo.t t3 on t1.f1=t3.f1 and t2.f1=t3.f1

    ...and if on different servers then create linked servers and use 4-part naming convention by preceeding the database name with the alias of the server.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  3. #3
    Join Date
    Oct 2002
    Location
    Western part of Georgia, USA
    Posts
    123
    Thanks so much! It was so easy that I am embarrased

Posting Permissions

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