Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Data from two different databases


Data from two different databases

Author
Message
Trainacomin
Trainacomin
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 26
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
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14967 Visits: 38985
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!

Trainacomin
Trainacomin
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 26
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.
Trainacomin
Trainacomin
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 26
I should clarify, both database have the same tables and columns. The data is different as one is an archive database.
michal.lisinski
michal.lisinski
SSChasing Mays
SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)SSChasing Mays (636 reputation)

Group: General Forum Members
Points: 636 Visits: 1090
Hi
You can use UNION operation to combine the results from two queries into single result set.
Regards
Mike
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search