Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7590165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:20:19+00:00 2026-05-30T20:20:19+00:00

Using SQL Server 2008, I am trying to figure out how to create a

  • 0

Using SQL Server 2008, I am trying to figure out how to create a query that returns a pivot table with a standard many-to-many relationship. This relationship defines which users belong to which roles and I want the table to list the user name along the side and the role names across the top. The ultimate goal is to have this output in SQL Server Reporting Services, so it doesn’t matter if SQL server generates the pivot results, or SSRS generates the results (is one method better than the other?). Here is my sample schema:

Users Table:

  • UserID
  • UserName

Rights Table:

  • RightID
  • RightName

RightsMembership Table:

  • UserID
  • RightID

I want the following output as a report in SSRS. Any help is appreciated.

       RightOne   RightTwo   RightThree   RightFour
jdoe       X          X
mjane      X                       X
ssmith                X            X           X

FYI: Roles can be added, so I would prefer not to have to hard code the role name or count in the query.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:20:20+00:00Added an answer on May 30, 2026 at 8:20 pm

    I Don’t Know about the Pivot Tables but you can achieve this in the SSRS as below

    Select UserName,
               RightName
    From users u INNER JOIN RightMembership rm on rm.UserID = u.UserID
                 INNER JOIN Rights r on rm.RightID = r.RightID
    

    Use this query as the Stored Procedure or Query and the Order By Accordingly and

    Create the Dataset and Datasource

    Insert matrix in the report

    In the rows select the UserName field From the Created Dataset
    In the columns select the RightName field from the created Dataset
    In the Data use this Expression below then you will get the desired output
    =IIF(Fields!UserName.Value = nothing,nothing,”X”) As the Data in the matrix

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using SQL Server 2008 Reporting services: I'm trying to write a report that displays
I am using SQL Server 2008 R2, I am trying to create a dataset
I am using SQL Server 2008, and trying to run the following query in
I am using sql server 2008 and I'm trying to build a query for
I'm using SQL Server 2008 (non-R2) and trying to use Report Builder 3.0. When
I am using SQL Server 2008 developer edition. I was trying to attach the
I am using SQL Server 2008 & 2005 (Express). I'm trying to extract part
I've just installed SQL Server 2008 Developer edition and I'm trying to connect using
I'm trying to export records from SQL Server 2008 to mdb file using OpenDataSource.
I'm trying to setup the Entity Framework with SQL Server 2008. I'm using Guids

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.