Note: this article is published on 08/08/2024.
This series of articles will discuss SQL Server Reporting Services, including the related Services:
- SSRS (1) --- Server Setup: SSIS, SSAS, and SSRS
- SSRS (2) --- Client Setup: SSDT and Report Builder
- SSRS (3) --- Report Build and Deploy as a VS Project --- this article
- SSRS (4) --- SQL Server Database Project in Visual Studio
A - Introduction
The services discussed include:
- SSIS --- SQL Server Integration Services
- SSAS --- SQL Server Analysis Services
- SSRS --- SQL Server Reporting Services
- SSDT --- SQL Server Data Tools
The first article of this series discussesed the Server side Instalation and Configuration. The second discussed the Client side (the Development Invironment) Installation and Configuration, inluding Visual Studio setup by installing Extentions and a Desktop app Report Builder. This article will make a sample of Report from Visual Studio Environment by using both the pre-setup SSIS, SSAS, Server and the SQL Server DAta Tools
This will be the content of this article:
- A - Introduction
- B - Create a report server project
- C - Create a report definition file (RDL)
- D - Set up a connection
- E - Define a Transact-SQL query for report data
- Add a table data region and fields to a report layout
- Preview your report
- F - Formating
- Date
- Currency
- Change text style and column widths
- G - Group data in a report
- H - Add totals to a report
- line Total
- Daily Total
- Grand Total
- Preview the report
- I - Add a Report Parameter
- J - Publish the report to the Report Server
- K - Export to Excel
B - Create a report server project
- In Visual Studio (VS), Right Click File > select New > Project from the File menu.

- In the Create a New Projuct page, search for "Report Server Project", and select Report Server Project, and then choose Next

- In the Project name box, enter "Tutorial" for the project name > Create

C - Create a report definition file (RDL)
Next, you create a report definition file (RDL). This process involves setting up the report within the project you created.
-
In the Solution Explorer pane, right-click the Reports folder. Select Add > New Item.

-
In the Add New Item window, select Report > Enter "Sales Orders.rdl" into the Name box > Add

- Report Designer opens and displays the Sales Orders report file in Design view.

D - Set up a connection
- In the Report Data pane, select New > Data Source.

- The Data Source Properties dialog opens with the General section selected > Select Embedded connection > Click Build

- Setup the connection

- Test the Connection > OK

- Back to Data Source Properties > named as AdventureWork3033

-
Select Credentials. Choose the Use Windows Authentication (integrated security) option.

- Select OK. Report Designer adds the AdventureWorks2022 data source to the Report Data pane.

E - Define a Transact-SQL query for report data
- In the Report Data pane, select New > Dataset or Right Click DataSet > Add DataSet,

then the Dataset Properties dialog opens with the Query section highlighted.

-
In the Name box, enter "AdventureWorksDataset".
-
Select the Use a dataset embedded in my report option.
-
From the Data source list, select AdventureWorks2022.
-
For Query type, select the Text option.
-
Enter, or copy and paste, the following Transact-SQL query into the Query text box.
SELECT
soh.OrderDate AS [Date],
soh.SalesOrderNumber AS [Order],
pps.Name AS [Subcat],
pp.Name as [Product],
SUM(sd.OrderQty) AS [Qty],
SUM(sd.LineTotal) AS [LineTotal]
FROM Sales.SalesPerson sp
INNER JOIN Sales.SalesOrderHeader AS soh
ON sp.BusinessEntityID = soh.SalesPersonID
INNER JOIN Sales.SalesOrderDetail AS sd
ON sd.SalesOrderID = soh.SalesOrderID
INNER JOIN Production.Product AS pp
ON sd.ProductID = pp.ProductID
INNER JOIN Production.ProductSubcategory AS pps
ON pp.ProductSubcategoryID = pps.ProductSubcategoryID
INNER JOIN Production.ProductCategory AS ppc
ON ppc.ProductCategoryID = pps.ProductCategoryID
GROUP BY ppc.Name, soh.OrderDate, soh.SalesOrderNumber, pps.Name, pp.Name,soh.SalesPersonID
HAVING ppc.Name = 'Clothing'
-
(Optional) Select Query Designer. The query appears in the text-based Query Designer. Select run to view the results of the query (
) on the Query Designer toolbar. The dataset displayed contains six fields from four tables in the AdventureWorks2022database. The query makes use of Transact-SQL functionality such as aliases. For example, the SalesOrderHeader table is calledsoh. -
Select OK to exit the Query Designer.
-
Select OK to exit the Dataset Properties dialog.
We have

-
The Report Data pane displays the AdventureWorksDataset dataset and fields.

Add a table data region and fields to a report layout
- Choose the Table object and drag it to the report design surface. You can also add a table to the report from the design surface. Right-click the design surface and select Insert > Table.

Report Designer draws a table data region with three columns in the center of the design surface.
- Drag the
Datefield from the Report Data pane to the first column in the table.

- Add the
LineTotalfield in the same way, creating a fifth column. The column label shows as "Line Total". Report Designer automatically creates a friendly name for the column by splitting "LineTotal" into two words.

Preview your report
While designing, preview your report frequently. By doing so, you validate the design and data connections and you can correct errors and issues as you go.
-
Select the Preview tab.

- Report Designer runs the report and displays it in the Preview view.

F - Format the Report
Formatting.
Date:
-
On the Design tab, right-click the cell with the
[Date]field expression and then select Text Box Properties.

-
Select Number, and then choose Date from the Category box. In the Type box, select January 31, 2000.

Currency

Change text style and column widths
You can add other formatting to your report by highlighting the header, and then adjusting the widths of the data columns.
-
Select the table so that column and row handles appear on the top and side of the table. The gray bars along the top and side of the table are the column and row handles.
-
Highlight the row containing column header labels and then select Format > Font > Bold.












. The Grand Total values display at the end of the report.














Maya ChopraPosted Sep 30, 2024, 3:23 AM
I like the way how you explain thing in your article, thanks for posting..
jose loraPosted Aug 25, 2024, 1:02 AM
I WOLD LIKE TO KNOW IF I CAN USE REPORT BUILDER IN ASP.NET CORE 8
jose loraPosted Aug 25, 2024, 1:02 AM
THIS CAN BE USED BY ASP.NET CORE