Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Data from two different databases Expand / Collapse
Author
Message
Posted Monday, June 24, 2013 10:08 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 1, 2013 3:18 PM
Points: 3, Visits: 14
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
Post #1466815
Posted Monday, June 24, 2013 10:13 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 7:44 AM
Points: 12,910, Visits: 32,015
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1466819
Posted Monday, June 24, 2013 1:25 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 1, 2013 3:18 PM
Points: 3, Visits: 14
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.

Post #1466876
Posted Monday, June 24, 2013 2:37 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 1, 2013 3:18 PM
Points: 3, Visits: 14
I should clarify, both database have the same tables and columns. The data is different as one is an archive database.
Post #1466905
Posted Monday, June 24, 2013 2:46 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 2, 2014 8:05 AM
Points: 285, Visits: 334
Hi
You can use UNION operation to combine the results from two queries into single result set.
Regards
Mike
Post #1466908
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse