SSRS Reports has the ability to use the identity of the current user as a built-in variable within the report. This means the user ID can be used as a filter for SQL queries against a data source, assuming the data source stores that same ID.
In order for this recipe to work correctly, we will need to add IDs to the database. We will modify the Dimension.Employee
table within the WideWorldImportersDW
database to hold a fictitious manager ID field. First, open SSMS and execute the following query against the WideWorldImportersDW
database:
ALTER TABLE [Dimension].[Employee] ADD [ManagerID] NVARCHAR(50)
Next, we will need to insert data into this column. In this example, you should replace the IDs shown with ones that will be valid in your organization or computer; the ones used here are for testing purposes:
UPDATE [Dimension].[Employee] SET [ManagerId] = 'ACSRV\ArcaneCode' WHERE [Employee Key] < 101 UPDATE [Dimension].[Employee] ...