Introduction to SQL Server 2005 Reporting Services
Tutorial / Sample Courseware Chapter
provided by Accelebrate
http://www.accelebrate.com • firstname.lastname@example.org 877 849 1850 phone • 866 566 1228 fax
Chapter 18: Reporting Services
In this chapter:
• • • • • The Reporting Services Architecture Using Report Designer Publishing a Report Using Report Builder Using Report Manager
• • • ProductReport1.zip ProductReport2.zip AWSales.zip
Reporting Services has a quite complex architecture. Microsoft shipped SQL Server Reporting Services.
Copyright © 2005 Accelebrate.Reporting Services For many years. There are a number of ways to get to Reporting Services programmatically. and now it’s a part of the core product. including SOAP and WMI interfaces. Report Builder is a simplified end-user tool for building reports. and report viewers. SQL Server did not have a good answer for creating attractive reports that summarize information in ways that make sense to business users. administration tools. Finally. Reporting Services was originally an add-on for SQL Server 2000. Like Notification Services. Report Designer is a developer tool for building complex reports. In this chapter. Inc
Introduction to SQL Server 2005 18-2
http://www.accelebrate. Report Manager is a Web-based administrative interface for Reporting Services.
The Reporting Services Architecture
For a relatively new product.com
. you’ll learn how to use Reporting Services to produce your own reports. The full Reporting Services architecture includes development tools.
Figure 18-1: Report Server architecture
In this chapter you’ll learn about these components: • • • • Report Server is the core engine that drives Reporting Services. Figure 18-1 shows a simplified diagram of the main Reporting Services components that we’ll be using in this chapter.
Using Report Designer
Reporting Services includes two tools for creating reports: • Report Designer can create reports of any complexity that Reporting Services supports.com
. Select the Business Intelligence Projects project type. or you can use a set of design tools to build a report from scratch. 4. 3. Inc
Introduction to SQL Server 2005 18-3
http://www. Select the Report Server Project Wizard template. Report Designer runs inside the Business Intelligence Development Studio shell. You can also use the design tools to modify a report created with the wizard. but requires you to understand the structure of your data and to be able to navigate the Visual Studio user interface. Like all wizards. You can make the following choices in the wizard: • • • • • • The data source to use The query to use to retrieve data Whether to use a tabular or matrix layout for the report How to group the retrieved data What visual style to use Where to deploy the finished report
To create a simple report using the Report Wizard.
Copyright © 2005 Accelebrate.Using Report Designer • The Report Server database stores report definitions. You can either use the Report Wizard to quickly create a report. directed primarily at business users rather than developers.accelebrate. Report Builder requires a developer or administrator to set up a data model before end users can create reports. Reports themselves can make use of data from many different data sources.
Using the Report Wizard
The easiest way to create a report in Report Designer is to use the Report Wizard. the Report Wizard walks you through the process in step-by-step fashion. and offers several ways to create reports. 2. Launch Business Intelligence Development Studio. Report Builder provides a simpler user interface for creating ad hoc reports.
We’ll start our tour of Reporting Services with Report Designer. follow these steps: 1. Select File New Project.
Figure 18-2 shows the full query designer interface. Name the new data source AdventureWorksDS. Name the new report ProductReport1 and pick a convenient location to save it in. 10. If the full query designer interface does not display by default.accelebrate. Click OK. Click the Edit button. 16. 15. 19. Log on to your test server. Click OK. Click the Query Builder button. 6.
Copyright © 2005 Accelebrate. 8. 9. 18. Click OK. 14. Click the Credentials button. 17. 11. Select the AdventureWorks database. 12. This will make this particular data source available to other Reporting Services applications in the future. Select Use Windows Authentication.Reporting Services 5. Read the first page of the Report Wizard and click Next. Check the Make This a Shared Data Source checkbox. 7. 13. Click Next. click the query designer toolbar button at the far left end of the toolbar. Inc
Introduction to SQL Server 2005 18-4
23. Check the Name. Select the Tabular layout and click Next. Color.Using Report Designer
Figure 18-2: Query Builder
20. Move the Color column to the Group area.
Copyright © 2005 Accelebrate. Click OK. Click Close.com
. 27. 26. 22. as shown in Figure 18-3.accelebrate. Click Next. 21. and ListPrice columns. and the other three columns to the Detail area. 24. Select the Product table and click Add. 25. ProductNumber. Inc
Introduction to SQL Server 2005 18-5
http://www. Click the Add Table toolbar button.
30. 33. 29.com
. Accept the default deployment location and click Next. open in Report Designer. Check the Preview Report checkbox. Click Next. 34. Name the report ProductReport1. Click Finish. Select the Stepped layout and click Next. Figure 18-4 shows the finished report. Select the Ocean style and click Next. 32.accelebrate. Inc
Introduction to SQL Server 2005 18-6
Figure18-3: Grouping columns in the report
Copyright © 2005 Accelebrate.
Modifying a Report
Now that you’ve created a report with the Report Wizard. Inc
Introduction to SQL Server 2005 18-7
http://www. and Properties windows are the standard Visual Studio windows. you should have no problem making changes here. The main design window lets you view the report itself.Using Report Designer
Figure 18-4: Report created by the Report Wizard
Figure 18-4 shows the main features of Report Designer: • • The Datasets window shows the data that is available to the report. you can modify it with the Report Designer. The Solution Explorer.accelebrate. If you’ve used any sort of visual report design tool in the past. work with the report in a layout designer.com
. You can see a preview of the report. Output. Among the possibilities here:
Copyright © 2005 Accelebrate. or work with the query that returns the data for the report.
2. Click in the textbox at the top of the report. Select a Descending sort type for the ListPrice column. 6. Use the Properties window to change the Value property of this control to Products By Color. Inc
Introduction to SQL Server 2005 18-8
http://www.Reporting Services • • • You can change the available data or the sort order for the report by modifying the query on the Data tab. 7. Hold down the mouse button and drag the cursor to the right to widen the Name column.com
. colors. 4.
9. Click on the header for the Product column. Click the Layout tab. Click the Data tab to view the query for the report. Click on the Preview tab to view the modified report. and so on.accelebrate.
To modify the report that you just created. where the report name is displayed. as shown in Figure 18-5. Place the cursor between the Name and Product Number columns to display a double-headed arrow.
Copyright © 2005 Accelebrate. You can resize or rearrange controls on the Layout tab. alignment. Place the cursor between the Product Number and ListPrice columns to display a double-headed arrow. You can use the Properties window to change properties of individual controls including their font. follow these steps: 1. 5. Hold down the mouse button and drag the cursor to the right to widen the Product Number column.
Create a query from the dataset. 3.Using Report Designer
Figure 18-5: Modified product report
Designing a Report From Scratch
You can also use Report Designer to build your own reports starting from scratch. Select File Close Solution to close the existing report. Create a Report project in Business Intelligence Design Studio. 4.com
. Select the Report Server Project template. Associate one or more datasets with the report.accelebrate. you’ll follow these steps to create a report: 1. follow these steps: 1. 3. 2. Select File New Project. 4.
Copyright © 2005 Accelebrate. 2.
To create a fresh report in Report Designer. Inc
Introduction to SQL Server 2005 18-9
http://www. Build the report layout. Select the Business Intelligence Projects project type. In general.
Click OK again to create the data source. 26. 9. Expand the dataset in the Datasets window to show the column names. 8. Sort the dataset in ascending order by Name. 7. Click Close. Name the new report ProductReport2. 11. 18.accelebrate. Expand them horizontally until each takes up about half of the List control.Reporting Services 5. 21. Click OK. 27. 16. 6. Right-click on the Reports node in Solution Explorer and select Add New Item. 24. Click the Query Designer toolbar button inside the Data tab to display the full query designer user interface. Double-click the List control. Select the Location table. Name the new report ProductReport2 and pick a convenient location to save it in. Expand the List control to the width of the report. Name the new Data Source AdventureWorksDS. Click the Edit button. 17. Figure 18-6 shows the report in layout view. 10. 22. Hover your mouse over the toolbox tab to display the available controls for the report. 19. 13. Connect to your test server and choose the AdventureWorks database. 12. Select the Report template. Drag the Name and CostRate columns from the Datasets window and drop them in the List control. 28. 15. 23. 14. 20. Click the Datasets dropdown and select <New Dataset> to open the Data Source dialog box. Check the boxes for the Name and CostRate columns. Click the Add Table button.com
. Click Add.rdl and click Add. Inc
Introduction to SQL Server 2005 18-10
http://www. Select the Data tab in the Report Designer. 25. Click the Layout tab to show the blank report layout.
Copyright © 2005 Accelebrate.
Select the Preview tab to see the report with data.com
.Publishing a Report
Figure 18-6: Designing a report from scratch
Publishing a Report
Creating reports in Business Intelligence Development Studio is good for developers. Inc
Introduction to SQL Server 2005 18-11
http://www. In order for the reports you build to be available to others.accelebrate. Before you do this. follow these steps:
Copyright © 2005 Accelebrate. you can use the Build and Deploy menu items in Business Intelligence Development Studio. but it doesn’t help users at all. To publish a report. you must publish them to your Reporting Services server. you need to check the project’s configuration to make sure that you’ve selected an appropriate server for the deployment.
To publish a report.
Figure 18-7: Setting the active configuration
7. this will be http://localhost/ReportServer. Figure 18-8 shows the completed Property Pages. Close the ProductReport2 project.accelebrate.Reporting Services 1. If you’re developing on the same computer where Reporting Services is installed.com
. Open the ProductReport1 project. 2. 3. Make sure the Configuration is set to Production and both the Build and Deploy checkboxes are checked. Fill in the URL for your Report Server. 5. Figure 18-7 shows the Configuration Manager. 8. 6.
Copyright © 2005 Accelebrate. Inc
Introduction to SQL Server 2005 18-12
http://www. 4. Click the Configuration Manager button. Set the Active Solution Configuration to Production. and you installed in the default configuration. Select Project ProductReport1 Properties.
Launch SQL Server Management Studio. 15. Right-click on the report and select View Report. Connect to your test server.Publishing a Report
Figure 18-8: Setting report project properties
9. 14. Expand the Home node in the Object Explorer tree to find the ProductReport1 project. Expand the ProductReport1 project to find the ProductReport1 report. 16.
Figure 18-9: Deploying a report
11. The Output Window will track the progress of BIDS in deploying your report. Select Build Deploy ProductReport1. 10. Click the Connect button in Object Explorer and select Reporting Services.com
Introduction to SQL Server 2005 18-13
http://www.accelebrate. 12. 13. Depending on the speed of your computer. Click OK.
Copyright © 2005 Accelebrate. building the report may take some time. as shown in Figure 18-9.
but it’s not the only way. Unlike Report Designer. supply your username and password. Read the first page of the Add New Data Source Wizard and click Next.
Copyright © 2005 Accelebrate. Instead. it depends on a data model: a preselected group of tables and relationships that a developer has identified as suitable for end-user reporting. If it’s not already open.com
. The report will open in your Web browser. 3.
Building a Data Model
Report Builder doesn’t let end users explore all of a SQL Server database. Click Next. 6.
Using Report Builder
Report Designer gives you one way to create reports for Reporting Services. Report Models contain entities that end users can use on reports. SQL Server 2005 also includes a tool directed at end users named Report Builder.Reporting Services 17. 8. 9. Click OK. Select the Report Model Project template. Name the new data source AdventureWorks and click Finish. To build a data model. you use Business Intelligence Development Studio. In the Connection Manager dialog box connect to the AdventureWorks database on your test server and click OK. 5. which is aimed at Developers. Inc
Introduction to SQL Server 2005 18-14
http://www. follow these steps: 1. 11. 10. launch Business Intelligence Development Studio Select File New Project. Report Builder presents a simplified view of the report-building process and is intended for business analysts and other end users. 12. Right-click on Data Sources in Solution Explorer and select Add New Data Source.
To create a data model. Name the new project AWSales and save it in a convenient location. 7. Data models contain three things: • • • Data Sources connect the data model to actual data. 2. If prompted. Select the Business Intelligence Projects project type.accelebrate. Data Source Views draw data from data sources. Click New. 4.
Select the Production. Right-click on Report Models in Solution Explorer and select Add New Report Model. 17. Inc
Introduction to SQL Server 2005 18-15
http://www. Click Finish.Using Report Builder 13.Product table and click the > button to move it to the Included Objects listbox. 15. Click Next.
Figure 18-10: Creating entities for end-user reporting
Copyright © 2005 Accelebrate. Select the Adventure Works data source view and click Next.SalesOrderDetail table and click the > button to move it to the Included Objects listbox. 21. and click Next. Select the Sales. 24. 19. Right-click on Data Source Views in Solution Explorer and select Add New Data Source View. 14.accelebrate. 23. 20. Read the first page of the Add New Data Source View Wizard and click Next. Select the AdventureWorks data source and click Next. Read the first page of the Report Model Wizard and click Next. 18. 22. Keep the default rules selection. Click the Add Related Tables button. 16. as shown in Figure 18-10.com
. Click Run to complete the wizard.
Figure 18-11: Reporting Services home page
To install Report Builder. That means that end users install it from the browser. 27. but once installed it's not a browser-based application. Click Finish.Reporting Services 25. 28. 26.
Copyright © 2005 Accelebrate. Choose the Update Statistics option and click Next. click Yes.accelebrate. Report Builder will automatically load up all of the available report models and wait for you to choose one to build a report from. Select Build Deploy AWSales to deploy the report model to the local Reporting Services server. this will have a URL such as http://ServerName/Reports (or http://localhost/Reports if you're running the browser on the same box with SQL Server 2005 itself). browse to your Reporting Services home page. If you get a warning that a file was modified outside the source editor. click the Report Builder link in the home page menu bar. Inc
Introduction to SQL Server 2005 18-16
http://www. To get started with Report Builder. Typically.
Building a Report
Report Builder itself is a ClickOnce Windows Forms application. Figure 18-11 shows the Reporting Services home page.
Click the Report Builder link. Depending on your operating system. 4.com
. After Report Builder is installed. you may have to confirm that you want to run the application. Figure 18-12 shows the new blank report that Report Builder will create. Open a browser window and navigate to http://localhost/Reports (or to the appropriate Report Server URL if you’re not working on the report server). 3. Inc
Introduction to SQL Server 2005 18-17
http://www. 2. Click OK.accelebrate. select the AdventureWorks report model and the table report layout.Using Report Builder
Figure 18-12: New report in Report Builder
Copyright © 2005 Accelebrate.
Drag the Name field and drop it in the area labeled Drag and Drop Column Fields. the Fields window shows the entities in the currently-selected table. Note that not everything in this window is a column in the table: the report model also contains aggregate entities such as Total Safety Stock Level and automatically calculated fields. 5. Beneath that.
Copyright © 2005 Accelebrate. Select the Product table. Inc
Introduction to SQL Server 2005 18-18
http://www.Reporting Services The Explorer window to the left of the design surface shows all of the tables in the report model. Click on Sales Order Details. 7. Drag the Total Order Qty field and drop it to the right of the Name field. 10.accelebrate. Click the Run Report button to produce the report shown in Figure 12-13.com
. 6. 11. 9. 8. Click on Special Offer Products in the Explorer window to show related child tables. Click where it says Click to Add Title and type Product Sales.
accelebrate. 15. 16.
Copyright © 2005 Accelebrate. Click OK. Select to sort by Total Order Qty descending. This will publish the report back to the Reporting Services server that you originally downloaded Report Builder from.com
Introduction to SQL Server 2005 18-19
http://www.Using Report Builder
Figure 18-13: Report in Report Builder
12. 14. 17. Name the new report Product Sales. Select File Save. 13. Click the Sort and Group toolbar button. Click Save.
as shown in Figure 18-14. known as Report Manager. you’ll see the report’s data.
Figure 18-14: Report in Report Manager
Copyright © 2005 Accelebrate. When you click on a report in Report Manager. Inc
Introduction to SQL Server 2005 18-20
Using Report Manager
The Web home page for Reporting Services provides a complete interface for managing reports (as well as other objects such as data sources and models) after they are created. is intended primarily for database administrators. but as a developer you should know about its capabilities for managing and modifying reports.com
. This interface.
Properties lets you adjust such things as the report’s name. Inc
Introduction to SQL Server 2005 18-21
http://www. data source. and end-user security. Subscriptions lets you create subscriptions to the report.accelebrate. Subscriptions allow you to set up periodic delivery of reports to end users by e-mail or file share. security credentials. History shows you saved snapshots of the report.com
.Using Report Manager Note that reports in Report Manager open in a tabbed interface. The four tabs allow you to perform various functions: • • • • View allows you to see the current data in the report.
Copyright © 2005 Accelebrate. caching.
Copyright © 2005 Accelebrate. Inc
Introduction to SQL Server 2005 18-22
Use Report Builder to create a report from the AdventureWorks data model showing the minimum and maximum order quantity for orders taken by each salesperson in the company.com
. You’ll find the necessary data in the SalesOrderHeader and SalesOrderDetail tables.
Click the Report Builder link.Solutions to Exercises
Solutions to Exercises
1. Drag the Max Order Qty field and drop it to the right of the Min Order Qty field. 10. 3. 7. 9. Select the AdventureWorks report model and the table report layout. 8. Click on Sales Order Details in the Explorer window. 4. 11. Click where it says Click to Add Title and type Sales Performance. Drag the Sales Person ID field and drop it in the area labeled Drag and Drop Column Fields. 5. Inc
Introduction to SQL Server 2005 18-23
http://www. Click the Run Report button to produce the report shown in Figure 18-15. Expand the Total Order Qty field in the Fields window to show the alternative fields beneath it.accelebrate. 12.
Copyright © 2005 Accelebrate.com
. Click OK. 2. 6. Select the Sales Order Header table. Open a browser window and navigate to http://localhost/Reports (or to the appropriate Report Server URL if you’re not working on the report server). Drag the Min Order Qty field and drop it to the right of the Name field.
Introduction to SQL Server 2005 18-24
Figure 18-15: Sales performance report
Copyright © 2005 Accelebrate.