SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full...

44
SQL Server Reporting Services 2008/2008 R2 Pradeep Dash

Transcript of SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full...

Page 1: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

SQL Server Reporting Services

2008/2008 R2

Pradeep Dash

Page 2: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

• Introduction and SSRS Architecture

• Creating a Simple Report… Step-By-Step

• Creating a Report Parameter

• Adding Grouping, Sorting and Formatting

• Creating a Subreport with Parameter

• Create a Chart

• Publishing a Report-Report Manager

Course Outline

Page 3: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Introduction and SSRS

Architecture

CS-1

Page 4: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Introduction and SSRS Architecture

CS-1

•Overview

•The Reporting Services Architecture

•Report Server

•Report Designer

•Report Builder

•Report Manager

Page 5: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Overview

• SQL Server 2008 Reporting Services (SSRS) is a server-based reporting platform that provides a full range of ready-to-use tools and services to help people throughout your organization create, deploy, manage, and use reports quickly and easily.

• With SQL Server 2008 Reporting Services (SSRS), you can retrieve data from relational, multidimensional, and XML-based data sources; publish reports that can be viewed in various formats; and centrally manage report security and subscriptions.

• The reports that you create can be viewed over a Web-based connection or as part of a Microsoft Windows application or SharePoint site.

Page 6: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

The Reporting Services Architecture

• The full Reporting Services architecture includes development tools, administration tools, and report viewers.

• There are a number of ways to get to Reporting Services programmatically, including SOAP and WMI interfaces.

• The major SSRS Architecture building blocks are,− Report Server is the core engine that drives Reporting Services.

− Report Manager is a Web-based administrative interface for Reporting Services.

− Report Designer is a developer tool for building complex reports.

− Report Builder is a simplified end-user tool for building reports.

− The Report Server database stores report definitions. Reports themselves can make use of data from many different data sources.

Page 7: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

The Reporting Services Architecture

Page 8: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Report Server• The report server is the central

component of a Reporting Services installation. It consists of a pair of core processors plus a collection of special-purpose extensions that handle authentication, data processing, rendering, and delivery operations.

• The processors support the integrity of the reporting system and cannot be modified or extended.

• A single report server instance is defined by the complete collection of processors and extensions that provide end-to-end processing, from the handling of the initial request to the presentation of a finished report.

• The report server is a stateless server that stores all properties, objects, and metadata in a SQL Server database. Stored data includes published reports, report models, and the folder hierarchy that provides the addressing for all items managed by the report server

Page 9: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Report Designer

• Report Designer is a collection of graphical query and design tools that are hosted within the Microsoft Visual Studio environment.

• Report Designer provides a Report Data pane to organize data used in your report, and tabbed views for Design and Preview so that you can design a report interactively.

• Report Designer also provides query designers to help specify data to retrieve from data sources and the Expression dialog to specify report data to use in the report layout.

• Report Designer is hosted in the Business Intelligence Development Studio, which is fully integrated with the Microsoft Visual Studio 2008 development environment.

• To use Report Designer, open the Start menu, point to Programs, point to Microsoft SQL Server 2008, and select Business Intelligence Development Studio. After you open Business Intelligence Development Studio, you can open or create a new project template. When you select a Report Server Project, the Report Designer opens.

Page 10: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Report Designer Layout

Page 11: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Report Builder

• Report Builder is a ClickOnce Windows Forms application that is accessed from the report server for easy centralized management.

• Using Report Builder, users can interactively explore the related data within the report model.

• Unlike Report Designer, which is aimed at Developers, Report Builder presents a simplified view of the report-building process and is intended for business analysts and other end users.

• Report Builder doesn't let end users explore all of a SQL Server database. 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.

• To build a table, matrix, or chart report, use a report layout template that contains predefined data regions and select a predefined report model, which contains report items such as data fields, then drag and drop the report items onto the data regions within the template.

• Model Designer: − Model Designer is a Reporting Services tool used within the Business Intelligence

Development Studio to define, edit, and publish report models that are used in Report Builder.

− A report model is a business description of the underlying database. It describes the data in terms of entities, attributes, and relationships (roles), which can then be used by Report Builder users to help them build ad hoc reports.

Page 12: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Report Manager

• Report Manager is a Web-based report access and management tool that you use to administer a single report server instance from a remote location over an HTTP connection. You can also use Report Manager for its report viewer and navigation features. You can use Report Manager to perform the following tasks: − View, search, print, and subscribe to reports.

− Create, secure, and maintain the folder hierarchy to organize items on the server.

− Configure role-based security that determines access to items and operations.

− Configure report execution properties, report history, and report parameters.

− Create report models that connect to and retrieve data from a Microsoft SQL Server Analysis Services data source or from a SQL Server relational data source.

− Set model item security to allow access to specific entities in the model, or map entities to predefined clickthrough reports that you create in advance.

− Create shared schedules and shared data sources to make schedules and data source connections more manageable.

− Create data-driven subscriptions that roll out reports to a large recipient list.

− Create linked reports to reuse and repurpose an existing report in different ways.

− Launch Report Builder 1.0 to create ad hoc reports that you can save and run on the report server.

Page 13: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Report Manager Layout

Page 14: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Creating a Simple Report…

…Step-by-Step

CS-2

Page 15: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Creating a Simple Report… Step-by-Step

CS-2

•BIDS

•Create a New Report Server Project

•Creating a Data Source

•Creating a Report

•Creating a Dataset

•Customizing the Report

•Report Preview

•Report Debug/Run

Page 16: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Open BIDS

• First we need to create new SSRS Project. − Open Business Intelligence Development Studio (BIDS) from start�

All programs.

− Select File� New� Project…

Page 17: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Create a New Report Server Project

• New project window should appear. Ensure you have Business Intelligence Projects selected on the left side (Project types). Select Report Server Project from templates window.

• Type name, select location, Solution Name usually is the same asproject name and should be updated when you type project name (name text box). Click ok to create new SSRS project.

Page 18: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Create a Shared Data Source

• Shared Data Source�Add� New Data Source.

• Data Source Properties:1. Provide Data Source Name

2. Database/conn Type

3. Connection String- Click Edit Button

• Provide Database Server Name

• Choose Authentication

• Select Database

• Click Test Connection

Page 19: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Creating a Report

• To add a new Report, Reports�Add� New Item…

• Select Report Template, Provide the Name

Page 20: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Creating a DataSet for the Report

• What is DataSet:− The DataSet object is central to

supporting disconnected, distributed data scenarios with ADO.NET.

− The DataSet is a memory-resident representation of data that provides a consistent relational programming model regardless of the data source.

− The DataSet represents a complete set of data, including related tables, constraints, and relationships among the tables.

• For our Simple-Report the dataset contains Query String (in our case SQL query) which is executed at run-time and results are stored in the dataset and used by the report.

Page 21: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Creating a DataSet for the Report

• To create new data set open "Report Data" pane if it is not there use view menu. Right click datasets folder and click Add Dataset

• In the Dataset Properties fill in dataset name and click New button next to "data source" drop down box.

Page 22: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Creating a DataSet for the Report

• Data Source properties window is displaying and now we can use our shared data source that we created at the beginning by select it in "Use shared data sourced reference" drop down box. Click ok.

• Once that is ready select Query Designer to setup query string.

Page 23: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Creating a DataSet for the Report

• Design your Query with Query Designer

• Press ‘OK’

• Check the Query, Press ‘OK”.

Page 24: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Customizing the Report

• Your Data Set is ready. Now you can create simple report table. To do this please open Toolbox (use view menu or icon on toolbar) and drag and drop text box and table item into design area.

Page 25: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Customizing the Report

• Drag and Drop your DataSet Fields from “Report Data” section on to table columns.

• You can add more table columns by right clicking on a column header and selecting Insert Column� Left/Right

Page 26: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Report Preview

• Click on Preview (Right side to ‘Design’ tab) to see the Report Preview

Page 27: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Run/Debug the Report

• Go to Main Menu Project� Project Properties

• Set the Debug �Start Item as current report (SimpleReport.rdl)

• Now Click the Run Button /F5

Page 28: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Create a Simple Report

Parameter

CS-3

Page 29: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Create a Simple Report Parameter

CS-3

•Creating a Report Parameter

•Getting Available Values for a Parameter

Page 30: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Creating a Report Parameter

• Right Click on Parameters on Report Data and select Add Parameter

• Set the Report Parameter Properties

• Parameter Name

• Prompt

• Data Type

• You can set available values (specifying values manually or from a query) and default values by visiting respective tabs.

Page 31: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Creating a Report Parameter

• Now that we have created a parameter we need to use it to filter the dataset. NOTE: There are multiple ways to filter data. We use the most common one and add filter to the SQL statement. Very often you might use stored procedures and pass parameters as a stored procedure argument.

• To add the filter to our SQL Select we just add the following where clause: WHERE (CONVERT(datetime, Date, 111) = CONVERT(datetime, @RecordDate, 111))

• To edit the Query Right Click on the dataset and click Query…

• In Query Designer pass the parameter with WHERE clause as @parameterName

Page 32: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Run/Debug the Parameterized Report

• Press F5/Click the Debug/Run button

• Select the Date and Press View Report Button

Page 33: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Getting Available Values for a Parameter

• Following the previous steps create a new dataset with a query to select a single field to be used as a parameter.

• With our current example I have selected Meter Name as another parameter, The query “SELECT DISTINCT Record_Meter_Name from Gas_Telemetry” is used for dataset DSMeterName.

• Create Another Parameter for the report following below steps using the

new dataset.

Step-1 Step-2

Page 34: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Getting Available Values for a Parameter

• Now I need to update the SQL query of my main report data sourceas follows,WHERE (CONVERT(datetime, Date, 111) = CONVERT(datetime, @RecordDate, 111)) AND (Record_Meter_Name IN (@MeterName))

• Run the Report, (you will able to select multiple Meter Names from the list)

Page 35: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Adding Grouping, Sorting and

Formatting to the report

CS-4

Page 36: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Adding Grouping, Sorting and Formatting to the

report

CS-4

•Adding a Group

•Adding Summary/Aggregate Value to

Group Footer- Subtotal

•Sorting the Detail Data

•Sorting the group data

•Applying Formatting and Style

Page 37: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Adding a Group

• Click Row Group� Details Section� Add Group� Parent Group

• Select Field for Group By

• Choose if you need Group Header and Footer Section

• Once the group is added you may need to hide/delete the other detail column

• To do so, right click on the Column header from the table and Select either Delete to delete the column

• Or select “Column Visibility” and from Column visibility window select Hide.

Page 38: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Adding Summary/Aggregate Value to Group Footer- Subtotal

• To get the summary/aggregate value for report footer follow below steps,

• Right Click a field in group footer section and select Expression…

• Provide the Expression/Formula for the summary field.

• Here I have taken the Avg of all recorded Avg Pressure.

• So the expression is=Avg(Fields!Average_Pressure.Value)

• Fields refer to all dataset fields available on the report.

Page 39: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Sorting the Detail Data

• From Tablix properties, select Sorting tab.

• Click on Add

• Select the Field and sort order.

• Click OK

• In the Layout pane, click the table so that column and row handles appear above and next to the table.

• Right-click the corner handle and then click Properties.

Page 40: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Sorting the Group Data

• Go to Group Properties, select Sorting tab.

• Click on Add

• Select the Field and sort order.

• Click OK

Page 41: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Applying Formatting and Style

• Right-click the cell with a field expression and then click Placeholder Properties . The Placeholder Properties dialog box appears.

• With General Tab you can set the Label, Value, ToolTip properties.

• Similarly with Number, Alignment and Font you can set the placeholder number format, horizontal alignment and font type, size, color etc respectively.

• With the Action tab you can define the behavior of the placeholder, you can set it to point to an URL as a link, you can link it to another report or bookmark.

Page 42: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

Applying Formatting and Style

• Also you can set the format from property window

Page 43: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,

The Simple Report…

• Now your report should look like…

Page 44: SQL Server Reporting Services 2008/2008 R2€¦ · The Reporting Services Architecture • The full Reporting Services architecture includes development tools, administration tools,