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


View Records That Are Associated With a User Table


View Records That Are Associated With a User Table

Author
Message
dedeod
dedeod
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 61
I would like to find a way to setup a user table with logins (UserID) in one column and a department number in another column. A single user might be associated with multiple department numbers. When a report is run I would like the user to only see department data for the departments they are associated with in the table.

The article below is close to what I need except that a user is only associated with ONE department. I will have some people that are over multiple departments and will need access to all of those.

[url=http://www.mssqltips.com/sqlservertip/1743/dynamically-control-data-filtering-in-sql-server-reporting-services-reports][/url]
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10714 Visits: 12017
I don't understand why you think the article you reference doesn't solve the problem. It certainly allows each user to be associated with (and therefor see data concerning) one or multiple offices, so the only change you appear to need is to change the word "office" to "department", ie it is purely a terminology difference.

Tom

dedeod
dedeod
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 61
Thanks for the response! The example looks like it works for employees that would be associated with only one office. Mine will have multiple offices (departments). Am I missing something in the example?
TomThomson
TomThomson
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10714 Visits: 12017
Look at the example beginning with this text:

the Report

In order to test the report, login as a particular user or launch Internet Explorer by right clicking on it, selecting Run As, and entering the credentials to use. I have setup two accounts for my test: Tom has access to all offices and Joe is restricted to just seeing two offices.


You'll see that when run by joe the report produces information for two offices, when run by tom it produces information for 6 offices.
According to the article, the user-office association is defined in the table declared like this:
CREATE TABLE [dbo].[UserOffice](
[UserOfficeKey] [smallint] IDENTITY(1,1) NOT NULL,
[UserAccount] [nvarchar](50) NOT NULL,
[OfficeKey] [smallint] NOT NULL
)
ALTER TABLE dbo.UserOffice
ADD CONSTRAINT pk_UserOffice
PRIMARY KEY CLUSTERED (UserAccount, OfficeKey)

This table allows multiple rows for each user since there's no unique constraint on the UserAccount column, so each user can be associated with multiple offices.

Tom

dedeod
dedeod
Grasshopper
Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)Grasshopper (18 reputation)

Group: General Forum Members
Points: 18 Visits: 61
Thank you for the clarification. I appreciate your help!
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