SQL Server Reporting Services (SSRS) is Microsoft's primary technology for delivering standard reports. As mentioned in the previous chapter, these types of reports typically contain a well-defined output that is known and developed by a member of the IT department ahead of time and delivered on a recurring basis to facilitate the regular daily, weekly, and even monthly decision-making needs of the business.
One of the great capabilities of SSRS is the fine-grained control it allows users over visualizations, layout, parameterization, and extensibility, providing for a level of customization that simply can't be matched by any other reporting tool in the Microsoft stack. In fact, it is this ability of control and customization that also makes SSRS well suited for the development and delivery of complex dashboards and scorecards, even though there are arguably more suitable tools (for example, PerformancePoint) for this purpose when requirements are more basic.
At the same time, such a great level of control comes with the cost of a higher-than-necessary development effort and, therefore, can often be viewed as an impediment to the delivery of information to the business. SSRS, despite having been marketed in the past as a self-service reporting tool via Report Builder, requires an IT skill set to develop all but the most basic reports. It is for this very reason that we have seen the rise of self-service reporting tools over the last few years.
In this chapter, we'll cover the main features and functionalities offered in SQL Server Reporting Services 2012, including a breakdown of report components, development experience, extensibility, and security. By the end of the chapter, readers should have an understanding of the capabilities offered in SQL Server Reporting Services.
Before diving into all the cool features and functionalities offered by SSRS, it is important to have a basic understanding of the primary components that make up an SSRS report as well as a mental model of how these components work together to deliver information to the business; which is, after all, the entire purpose of standard reporting.
The primary components of an SSRS report are as follows:
The following diagram shows how data flows from the source system through these components and out to the end user:
A data source is typically the first object created while building an SSRS report and contains all the information necessary to make a connection to a source system. The source system could be a SQL Server database, Analysis Services cube, a SharePoint list, or some other type of business application database such as Oracle.
While most reports typically pull data from a single data source, it is possible to pull data from multiple sources. In fact, a single report can be based on multiple data sources and multiple datasets. The following screenshot shows the full list of data sources that can be used with SSRS 2012 right out of the box:
Data sources use credentials to authenticate with the source system. Credentials can be stored with the data source or determined at runtime. Some Reporting Services features, such as subscriptions and snapshots, require a data source with stored credentials. We will cover credentials in more detail toward the end of this chapter in the section on security.
There are two types of data sources: shared and embedded. A shared data source exists as a standalone object outside of the SSRS report and can be reused and referenced by multiple SSRS reports. An embedded data source is specific to a single SSRS report. If you open an SSRS report file in a text editor, you can find a section (shown in the following screenshot) that contains the details of all the data sources included in the report. Notice that the snippet for the shared data source (DataSource2
) only includes the information needed to locate the shared data source object on the report server, while the snippet for the embedded data source includes a connection properties section with all the information needed to connect to the source system.
One of the main benefits of using a shared data source is that it makes managing changes easier. This is especially true for large organizations, where you may have hundreds of reports based on the same relational source system. Imagine the headache and effort required to update the connection details for all of those reports if the source system is migrated to a new server. However, there are certain scenarios where an embedded data source is the only option. One example where the data source must be embedded is when you want to use an expression to dynamically control the destination of a data source object. Expressions will be covered later in this chapter.
A dataset is best thought of as a two-dimensional table structure based on the results of a query that has been executed against a report data source such as that displayed in the following screenshot:
This is not meant to imply that the results of the query are materialized in a physical structure, although that is an option if caching is configured.
Caching the result set of a query may seem wasteful. However, when viewed from a more holistic perspective, the benefits can be substantial. Given the nature of standard reporting—where the same reports are being run by large numbers of users—the ability to cache the data retrieved from the source system can provide considerable performance gains and greatly reduce the load placed on the source system. We'll cover this topic in more detail later in the chapter.
While creating a dataset, the developer first chooses the data source, which can be a shared data source referenced by the report or an embedded data source created and contained within the report. Once the data source has been selected, a query is created—the results of which will be made available as a two-dimensional structure—like the one in the preceding screenshot, which can then be consumed by the various report items.
It is important to understand that the use of the word "query" in the preceding paragraph is in the most general sense. The type of query is completely dependent on the data source. For example, if the data source is a relational database, the query could be a standard SQL select statement, or it could be the result set from a stored procedure. On the other hand, if the data source is an Analysis Services database, the query could be an MDX query (for a multidimensional cube), a DMX query (for a data mining model), or even a DAX query (for a tabular model that is new to SQL Server 2012).
Dataset queries can be entered manually as text or constructed using the graphical query designer shown in the following screenshot. The graphical query designer is helpful when the report author is not very familiar with the query language. However, report authors who are more proficient in the query language are likely to prefer the manual entry method or a combination of the two.
Though not a requirement, when the data source is a relational database, it is considered good practice to use a stored procedure to retrieve data for the dataset instead of a query embedded in the report. This offers an additional layer of encapsulation that comes in handy if/when minor changes are required at a later point in time. There may also be potential performance benefits through query parameterization and planned cache reuse on the source system, although thorough testing is the only way to be sure.
The Query Designer window is as follows:
Just as with the data source component, a dataset component can be shared or embedded. A shared dataset exists as a standalone object and can be referenced by multiple reports, while an embedded dataset is specific to a single report. A shared dataset cannot be based on an embedded data source; it must be based on a shared data source.
Datasets can be filtered to limit the data displayed on a report. However, it is typically better to push the filter down into the query defined in the dataset. This will maximize performance by only retrieving data from the source that needs to be displayed in the report. When the filter is applied to the dataset itself, all the data is retrieved from the data source and pulled into the dataset object, after which the filter is applied before data is consumed by the various report items.
Report items refer to the visual items that are placed directly on the report (referred to as the report body during authoring) that display information to the user. A report item can be a table, chart, gauge, map, or any of a number of different items.
Just as a dataset is linked to a specific data source, a report item is linked to a specific dataset. Looking at it from the other direction, many report items can be linked to the same dataset just as many datasets can be linked to the same data source. The following diagram helps you to visualize the cascading one-to-many relationship between these primary report components:
Report items can also be shared just like datasets and data sources. Shared report items, referred to as report parts can be based on either a shared dataset or an embedded dataset. When based on an embedded dataset, the dataset is wrapped up with the shared report part as a single unit and made available to other report developers. By creating shared report parts and reusing existing ones, the speed of report authoring can be greatly increased.
Report items can be published to Report Server as report parts. Report authors using Report Builder to create new reports can save time by leveraging the existing report parts instead of recreating them in each report.
The extended use and administration of shared report parts is a bit more complex than shared datasets and shared data sources, and outside the scope of this book. Please check out the following TechNet article for more information: http://technet.microsoft.com/en-us/library/ee633670.aspx
The following is a list of the report items available right out of the box with SSRS 2012 along with basic descriptions of each:
Table and matrix report items are based on the same underlying structure, which is known as the tablix . A table is a tablix without row/column groups, while a matrix is a tablix with row/column groups. See the following screenshot for an example of the differences while displaying data in a table (left) versus a matrix (right).
A KPI is a type of metric consisting of three to four measures that together provide information on how well the business is progressing towards a goal. These are very common in Business Intelligence dashboards or summary reports.
The following is a list of the measures that make up a KPI metric:
In addition to the objects listed earlier, there are custom report items that you can obtain from third-party sources if the visualization required is not offered out of the box.
18.117.99.152