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

joining multiple databases in one Sr... Expand / Collapse
Author
Message
Posted Tuesday, June 25, 2013 10:25 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 01, 2013 6:10 AM
Points: 3, Visits: 20
hi guys
I need help with an issue that I've got
scenario
I have multiple branches around australia with each branch having it's own db
each db contains the same information required for the branch itself
e.g.
branch a Has first name / last name
branch b has first name / last name
of course the fields have their own unique entries
e.g.
James in branch a
John in branch b
objective
creation of report in ssrs with a join of multiple databases
is it possible using an expression or anything else at all
thanks in advance to who ever can help me
Post #1467443
Posted Wednesday, June 26, 2013 8:26 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 10:07 AM
Points: 11,939, Visits: 10,973
If the databases are on the same server you can do this by using the full naming convention.

[database].[schema].[object]

If they are on different servers you will need to setup link servers and use 4 part naming.

[linkserver].[database].[schema].[object]


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1467700
Posted Wednesday, June 26, 2013 8:29 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 10:06 AM
Points: 12,741, Visits: 31,046
you'll run into permissions problems accessing, say 10 databases in a single query;
the calling user would need at least read permissions in every single database for the specific table(s) involved..



i think you'll need to create a procedure, featuring EXECUTE AS with a user that has read permissions in all those databases, and then grant execute to that procedure to the groups that contain the users that will be using this report.

even better would be using a certificate, which i have no experience doing, but is the preferred way for permissions issues like this, i think.


--the EXECUTE AS must be a user in the database(s)...not a login
CREATE procedure pr_CallBoostedSecurityProcess
WITH EXECUTE AS 'superman'
AS
BEGIN
SELECT ColumnList FROM db1.dbo.Table1 UNION ALL
SELECT ColumnList FROM db2.dbo.Table1 UNION ALL
SELECT ColumnList FROM db3.dbo.Table1 UNION ALL
SELECT ColumnList FROM db4.dbo.Table1
END




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 #1467705
Posted Wednesday, June 26, 2013 2:54 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 01, 2013 6:10 AM
Points: 3, Visits: 20
so it can be done...
I am getting a lot of people saying in Ssrs you can't connect more then one database per report
Post #1467879
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse