I will write steps to create an employees report department wise. We can pass department name via parameter.
-------------------------------------------
Create a Blank report
Then we need to add dataset
We should click on Add data set, then write server and database name, where our data is.
Press ok and then press the Query Designer button to design a query for the report.
I have selected these columns, this is my query, I am passing parameter
Department.Name = @Name.
SELECT
HumanResources.Employee.NationalIDNumber
,HumanResources.Employee.BusinessEntityID AS [Employee BusinessEntityID]
,HumanResources.Employee.HireDate
,HumanResources.Employee.SalariedFlag
,Person.Person.FirstName
,Person.Person.LastName
,HumanResources.EmployeeDepartmentHistory.DepartmentID
,HumanResources.EmployeeDepartmentHistory.BusinessEntityID AS [EmployeeDepartmentHistory BusinessEntityID]
,HumanResources.Department.Name
FROM
HumanResources.Employee
INNER JOIN Person.Person
ON HumanResources.Employee.BusinessEntityID = Person.Person.BusinessEntityID
INNER JOIN HumanResources.EmployeeDepartmentHistory
ON HumanResources.Employee.BusinessEntityID = HumanResources.EmployeeDepartmentHistory.BusinessEntityID
INNER JOIN HumanResources.Department
ON HumanResources.EmployeeDepartmentHistory.DepartmentID = HumanResources.Department.DepartmentID
WHERE
HumanResources.Department.Name = @Name
--------------
Then I created a new dataset to get department name from department table and then I will link this dataset to my parameter to get department values.
Then, open the properties of name parameter.
Open Available values then > get values from dataset > select a new dataset that we created in previous step, and then select value and name field. Check image below.
Then, we should insert a table to get/display our data, select columns as per requirements.
Now we can save the report and open the SQL Server Reporting Service to check our report.
I am selecting Information Services to get employees from this department.
Lets see
We are getting the data, we can do some formatting on date columns, font sizes and alignments.
You can add company logo, export the report in excel or pdf format, etc.
Thanks.
No comments:
Post a Comment