









Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!










SQL Server Technical Article
Summary: This paper introduces SQL Server 2005 Report Builder and demonstrates how to build an end-to-end ad hoc reporting solution for enterprise customers using Report Builder and SQL Server 2005 Analysis Services OLAP. We also highlighted a few product limitations as well as enterprise considerations. It is based on a real world implementation by Microsoft Business Intelligence Center of Excellence.
Author: Tian Ying He, Carolyn Chau
Project Editor: Deborah Dinzes
Published: September 2006
Applies To: Microsoft® SQL Server™ 2005 Reporting Services
Microsoft® SQL Server™ 2005 Analysis Services
The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This White Paper is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, email address, logo, person, place or event is intended or should be inferred.
F 6 D 9 2006 Microsoft Corporation. All rights reserved. Microsoft, SQL Server, and Visual Studio are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners.
Many organizations have adopted Microsoft® SQL Server™ Reporting Services and Analysis Services OLAP as part of their business intelligence platform. SQL Server 2005 Reporting Services introduces a new end-user product - Report Builder, which enables business users to create ad hoc reports based on information stored in both relational and OLAP data stores.
Report Builder is a ClickOnce application developed using the Microsoft .NET Framework version 2.0 and Windows Forms technology. It is included in SQL Server 2005 Enterprise, Standard, and Workgroup editions. With Report Builder, business users can create their own reports without having to understand the underlying database schema, Transact-SQL or MDX query syntax, or developer tools such as Microsoft Visual Studio®. Report Builder comes with templates for table, matrix, and chart reports. Ad hoc reports can be created by simply selecting a report layout template and then dragging data fields to a report design area. Report Builder supports commonly used reporting features, such as filtering, grouping, sorting, and the creation of formulas. Reports created using Report Builder can be saved to a Reporting Services report server. They then can be managed using Report Manager and SQL Server Management Studio in the same way as other reports developed using SQL Server Business Intelligence Development Studio and Report Designer. Report Builder not only provides a simple report authoring experience, but it also makes the database schema transparent to business users by creating a business-oriented semantic layer called a report model. Report models are described in an XML-based Semantic Model Definition Language (SMDL). For details on SMDL, please refer to SQL Server Books Online. SQL Server Reporting Services reports, including reports created using Report Builder, are saved using Report Definition Language (RDL), an XML based language used to define reports. SQL Server Reporting Services provides a role-based security model. Only individuals with assigned permissions can access Report Builder, which is accessed through a URL or from Report Manager. Reports created using Report Builder can also be secured based on user’s role assignments. An overview of the SQL Server ad hoc reporting architecture is shown in Figure 1 , which includes the following major components:
Figure 1 SQL Server 2005 Ad hoc Reporting Architecture
There are a few limitations when creating Reporting Services reports using Report Builder against Analysis Services OLAP data sources.
Ad hoc reporting capabilities are highly valued by information consumers. With Microsoft SQL Server 2005, ad hoc reports can be built against both OLAP and relational data sources. Figure 2 describes major steps in delivering an end-to-end solution for ad hoc reporting using SQL Server 2005 Reporting Services and Analysis Services, starting with analyzing business requirements.
Figure 2 Development Life Cycle of SQL Server Ad Hoc Reporting In this paper, we will discuss how to design, build, and deploy report models and how to author and publish Report Builder reports to a report server.
Though a report model can be generated to expose the measures and dimensions of an OLAP cube, without careful design, you may find the model generated doesn’t provide a very friendly user experience for ad hoc reporting. Since a report model will be used by business users, it is important that it presents data in the way that is business-oriented rather than data-centric. For relational databases, SQL Server provides Model Designer, a tool that allows a report model to be manipulated and
dimension attributes in Report Builder, the property InstanceSelection of those dimension attributes needs to be set to DropDown in your OLAP cube. See Figure 6.
Figure 6 InstanceSelection Property of Dimension Attributes
When generating a report model based on an OLAP cube, fact dimensions will be combined with related measure groups rather than result in a different report model entity. For example, given a cube with a “Customer” measure group and a “Customer Dimension” fact dimension, both of them are based on the same fact table. The report model generated will contain a single entity with all the measures of “Customer” and all the dimension attributes of “Customer Dimension”. This could result in a bad user experience because dimension attributes and measures will be listed in the same folder in Report Builder. It is recommended to create non-fact dimensions in the cube to support ad hoc reporting using Report Builder.
Since the names of OLAP cube objects will be used directly in the report model, it is recommended that you use business-friendly names when possible. Keep in mind that renaming cube objects can be costly, as a cube can be used by other applications. Changing the names in a cube that is being used in another application could cause the application to break.
A data dictionary needs to be created and published for ad hoc reporting. At minimum, it should provide descriptions of data fields and the relationships between data fields.
Clickthrough features of Report Builder are enabled on measure attributes and aggregate attributes by default, regardless of what drillthrough action is defined in the cube.
From an Analysis Services OLAP cube, a report model can be automatically generated using either Report Manager or SQL Server Management Studio. Unlike models generated from relational data sources, report models generated from OLAP cubes cannot be edited using Model Designer. You can edit the .smdl file directly, but this is not recommended. If there are any schema changes in the OLAP cube, the model needs to be regenerated. You must be a database administrator on the Analysis Services database to generate the report model. You must first connect to the database before a report model can be generated. You will then define a data source for Reporting Services and generate the model.
To create a report model using Report Manager, you first need to define a data source. Open Report Manager by specifying the URL of the report server, which is by default http:// MyServer/Reports (or http://localhost/Reports if you open an Internet browser on the report server itself). Click the New Data Source button on the toolbar, and type a name for the
data source, such as “Adventure Works”. For Connection type , select Microsoft SQL Server Analysis Services. For Connection string , type a connection string to the OLAP cube, for example, “Data Source=(local); Initial Catalog=Adventure Works DW”. For Connect using , select Windows integrated security or one of the other authentication methods and click OK. A data source will be created. To generate the model, select the new data source. The Properties tab of the data source should open, or you can select it. Click the Generate Model button as shown in Figure 7. You will be prompted for a model name and a location to store the model.
Figure 7 Generate Report Model with Report Manager
To create a report model using SQL Server Management Studio, you must first connect to a report server. After that, right click the Home folder and select Create New Data Source. Type the name of the data source, such as “Adventure Works.” Select the Connection page and in Data source type , select Microsoft SQL Server Analysis Services. For Connection string , type a connection string to the OLAP cube, for example, “Data Source=(local); Initial Catalog=Adventure Works DW”. Select Windows integrated security and click OK to finish. See Figure 8.
Figure 8 Create Data Source with SQL Server Management Studio Finally, right-click the new data source and select Generate Model.
Although a report model created from a relational data source inherits a unique GUID identifier, item identifiers in Analysis Services-based models are textual. Therefore, each time a model is generated, the item will receive the same identifier. The reports created on a previous model will run seamlessly against the new version of the model. If there are any updates on the OLAP cube schema, such as renaming objects, ad hoc reports created using old models may no longer work.
You can save the report model to a local drive as an .smdl file. In an enterprise environment, this feature is especially useful when you develop report models in a development environment and want to deploy them to a production environment. You can save a report model by using either Report Manager or SQL Server Management Studio. Use the Edit option to save the model. You can then specify a model name for the .smdl file. It can also be done programmatically by using SQL Server Reporting Services Web Services.
SQL Server 2005 Report Services provides various tools with which to deploy your report model. Developers may prefer SQL Server BI Development Studio or Report Manager while system administrators may favor SQL Server Management Studio or customized installation packages. Report models can be deployed either manually using tools or programmatically using the Report Server Web service.
Catch e As SoapException Console.WriteLine("Error : " + e.Detail.Item("ErrorCode").InnerText + " (" + e.Detail.Item("Message").InnerText + ")") End Try Creating Data Source Dim dsDefinition As New DataSourceDefinition dsDefinition.Extension = "OLEDB-MD" dsDefinition.CredentialRetrieval = CredentialRetrievalEnum.Integrated dsDefinition.ConnectString = "data source=" + MyServer + ";initial catalog=Adventure Works DW" dsDefinition.ImpersonateUserSpecified = True dsDefinition.Enabled = True dsDefinition.EnabledSpecified = True Try rs.CreateDataSource("Adventure Works", "/", False, dsDefinition, props) Catch e As SoapException Console.WriteLine("Error : " + e.Detail.Item("ErrorCode").InnerText + " (" + e.Detail.Item("Message").InnerText + ")") End Try Associating Report Model with Data Source Dim ds() As DataSource ds = rs.GetItemDataSources(ModelName) Dim dsref As New DataSourceReference dsref.Reference = DataSourceName ds(0).Item = dsref Try rs.SetItemDataSources("/Adventure Works Model", ds) Catch e As SoapException Console.WriteLine("Error : " + e.Detail.Item("ErrorCode").InnerText + " (" + e.Detail.Item("Message").InnerText + ")") End Try
Report models can be secured at different levels. Choose the right level for your environment and business needs. You can use Report Manager or Management Studio to set security on the model and Report Builder. However, to set security on a model item, you must use Management Studio.
After a report model is deployed to the report server, business users can start creating ad hoc reports using SQL Server Report Builder.
One of the commonly used approaches to control access to Report Builder is through Windows security groups. For example, you can create a security group named “AdventureWorksAnalysts” for Report Builder users. To give users access to Report Builder, you need to perform the following tasks:
Report Builder is a ClickOnce Windows Forms application. It can be started either from Report Manager or from the Report Builder URL. Report Builder is automatically installed on the client’s computer when it is started for the first time. In Report Manager, go to http:// MyServer/Reports and click the Report Builder button on the Home page to install and start Report Builder.
Report Builder will load with all the available report model perspectives and templates, as shown in the illustration below. Users select a model and a report layout (Table, Matrix or Chart) to start. When the user selects an OLAP cube-based model, all the perspectives are listed. Users cannot select the top-level model; they must select a perspective, which then loads its entities and fields in the Entities and Fields panes. If a Report Builder report contains items that are not within the single perspective, an error can occur when attempting to run the report.
Figure 9 Selecting a Perspective and a Template
After selecting a perspective and a template, users create a report by dragging data elements from the field list to the design area. As fields are dropped on the template, Report Builder builds the query in the background. The following illustration shows how Report Builder would appear if a user selected the Customer perspective.
Figure 10 Creating and Editing Reports in Report Builder Within the Customer perspective, there are four entities. An entity is a collection of related data that has fields that uniquely identify an instance of the entity. The fields belonging to the Location entity are listed in the Fields pane. Report Builder preserves the relationship of the underlying data and uses it to control the navigation among entities. To test the report, click the Run button. The report is processed on the report server and then rendered in Report Builder. To continue revising the report, click Design Report. If there is an error, Report Builder will display a dialog box with error messages.
Click-once application, easy to deploy and manage
Integrated into Visual Studio
Cannot import Report Designer reports Can work with reports built in Report Builder
When creating ad hoc reports using Report Builder against OLAP data sources, MDX queries are automatically generated by the tool. Report Builder allows users to create reports freely; how users navigate the report model will determine the structure of the MDX query, which could impact report performance. For example, it is possible to navigate via two different roles from a dimension or apply separate filters on columns, which might require using aggregate functions over a huge data set. One should be very careful not to just drag in fields from any old node in the tree that looks like it might be what you're looking for. The instances of that entity to which your fields are referring will depend on the path you used to get there. Also, Report Builder’s ability to generate clickthrough reports on any value could result in huge result sets that negatively impact the performance. Due to those performance considerations, it is recommended to consider deploying ad hoc reporting to a separate environment from managed reports for enterprise customers. To track the MDX queries generated by Report Builder, you can use SQL Profiler to capture the incoming SQL commands or enable query logging by changing the < RStrace > setting in the web.config file located in your ReportServer install directory.
Like other Reporting Services reports, Report Builder reports are saved in RDL format. When you create a report in Report Builder, you are really creating a report definition, which is a file that contains the definition and metadata used to generate the final query. The data of a report is generated at run time. By default, the report definition is saved as an .rdl file on the report server from which Report Builder was started. The actual data displayed when the report runs is not saved in the .rdl file. When you save an .rdl file to the report server, this is called publishing a report. Publish the report definition to report server when you want to regularly run the report and view the current data, or if you want to share the report with others in your organization. Ad hoc reports can be saved to a user’s local drive if the user chooses not to publish the report. The report can be edited at a later time and published to a different report server. With the right permissions, an ad hoc report can be published to report server directly. You can then assign permissions to the report to control who has access to your reports. The following illustration shows the sample Report Builder report rendered in Report Manager.
Figure 13 Ad hoc Report Published on a Report Server Report Builder reports are exactly like reports created using Report Designer except that Report Builder must use a model as a data source. After a report is published or saved, however, it will work the same way as other Reporting Services reports. It can be opened and edited using either Report Builder or Report Designer. Keep in mind that Report Designer provides more formatting and processing functionality than Report Builder. In another words, Report Designer can read and modify reports created using Report Builder but not vice versa. After an .rdl file has been modified in Report Designer, it cannot be edited in Report Builder.
In this article, we have provided an overview of SQL Server 2005 Reporting Services Report Builder tool and walked you through major steps to build an end-to-end ad hoc reporting solution against an Analysis Services OLAP cube. We also highlighted a few product limitations as well as enterprise considerations. Integrating with SQL Server 2005 Analysis Services, Report Builder gives users the power to generate their own reports against their organization’s OLAP data stores.