Data from two different databases

  • I'm new to the forum so I hope this is the right place to ask this question.

    I have a production and an archive database. I want to create a way to pull a combined report with data from both databases.

    The databases are identical and on the same SQL instance.

    I'm looking for the best solution to fit my needs.

    Can I create a view that will pull from views already created in both databases?

    Would SSAS or SSIS be more helpful in this?

    Ultimately I need to be able to run a report that pulls information from both databases into a single report where it looks like it comes from one data source.

    Thanks!

    Clint

  • Trainacomin (6/24/2013)


    I'm new to the forum so I hope this is the right place to ask this question.

    I have a production and an archive database. I want to create a way to pull a combined report with data from both databases.

    The databases are identical and on the same SQL instance.

    I'm looking for the best solution to fit my needs.

    Can I create a view that will pull from views already created in both databases?

    Would SSAS or SSIS be more helpful in this?

    Ultimately I need to be able to run a report that pulls information from both databases into a single report where it looks like it comes from one data source.

    Thanks!

    Clint

    if they are on the same server, you can just use three part naming conventions.

    if they are on separate servers, you can add a linked server, and use full four part names.

    SELECT T1.*,T2.*

    FROM PRODUCTION.dbo.MyTable T1

    INNER JOIN Archive.dbo.OtherTable T2

    On T1.Keys = T2.Keys

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • This works thanks!

    Since both databases are identical is there any way I can filter on a field and it search both databases? Or do I have to do it in separate select queries?

    I'd like to use this in SSRS but only have one filter to use for the report.

  • I should clarify, both database have the same tables and columns. The data is different as one is an archive database.

  • Hi

    You can use UNION operation to combine the results from two queries into single result set.

    Regards

    Mike

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply