Beginning SQL Server 2005 for Developers From Novice to Professional phần 10 pptx

59 439 0
Beginning SQL Server 2005 for Developers From Novice to Professional phần 10 pptx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

454 CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES The Application Layer At the application layer level, you will find report design tools, configuration tools, and custom applications that use Reporting Services. Let’s see how they’re used. Web Browser The simplest way to access a report server is using a browser. On the report server, all the items (such as reports, report models, and shared data sources) are organized using a folder hierarchy. The folder hierarchy looks like a file system, but actually all folders and items are stored in SQL Server databases. You can navigate through this hierarchy and view reports using a browser. The path to a report will be included in the URL used by the browser to display the report. For example, one of the reports we will create in the demo section “Building a Report Model” can be viewed with a browser using this URL: http://localhost/Reports/Pages/Report.aspx? ItemPath=%2fAd+Hoc+Report. Another use for a web browser is web-based management using Report Manager. Report Manager is an ASP.NET web application used as a management tool for Reporting Services. Report Tools A new option in SQL Server 2005 Reporting Services is the ability to create report models and ad hoc reports. A report model hides the complexity of a report. Based on a model, a business user can create with limited technical knowledge ad hoc reports. You will see them at work in the examples later in the chapter. To create reports, report models, or ad hoc reports, you have several options from Notepad to third-party tools. I will not talk about Notepad, but I will mention briefly the other options. Business Intelligence Management Studio Based on a Visual Studio 2005 shell, Business Intelligence Management Studio is the tool that allows you to create Business Intelligence projects. For Reporting Services you have three project templates available: Report Model Project, Report Server Project, and Report Server Project Wizard. Using the project templates will actually start the Report Designer and the Model Designer tools, which are design tools for creating the reports and report models. Configuration Tools For Reporting Services configuration and management, you have several tools at your disposal. We have seen these tools already within the book, but let’s take a moment to see how they fit within Reporting Services. SQL Server Configuration Manager If you want to configure SQL Server 2005 components services or network libraries, you will use this tool. Dewson_5882C14.fm Page 454 Tuesday, January 10, 2006 2:35 PM CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES 455 Surface Area Configuration This tool will help you to reduce the options of a potential attacker by stopping or disabling unused components. For Reporting Services, you can enable or disable the following features: • Web services request and HTTP access: If you don’t use a client application that requires Reporting Services web service, you can disable this feature. • Scheduled events and report delivery: If you only require “on-demand” report delivery, then you can disable this feature. • Windows Integrated Security: In order to access data sources, you need some credentials. If you disable the Windows Integrated Security feature, you will reduce the probability that a user’s identity may be used without the user’s consent. To access data, you will have several options for obtaining credentials such as prompted credentials, stored credentials, or no credentials. Report Manager I already mentioned this web-based application that allows you to manage a report server. If you don’t want to install any client utilities on your machine, then the best management tool for you is Report Manager. Reporting Services Configuration Tool This tool allows you to configure and modify the settings for a reporting services installation. You can configure the virtual directories used by a report server or by the Report Manager application; you can also configure service accounts, report server databases, or e-mail delivery. If you want to scale-out reporting services, you will need this tool. SQL Server Management Studio You should already be familiar with this tool that allows the central management for all SQL Server component servers and it can replace Report Manager. Command Line Tools In addition to graphical tools, Reporting Services comes with several command line utilities such as rs (for scripted operations), rsconfig (for configuring the report server connection to the report server database), rskeymgmt (for encryption key management), and sac (the command line version of Surface Area Configuration). Custom Applications The extensible architecture of all Reporting Services components gives you the possibility to develop custom applications for the complete reporting life cycle. You can build new report designers, management tools, or just use reports in your applications. I want to remind you that you can use Report Viewer controls, a set of two freely redistributable controls that can work in local and remote mode. In local mode, you can display reports without connecting to a report server. Dewson_5882C14.fm Page 455 Tuesday, January 10, 2006 2:35 PM 456 CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES The Server Layer At the server layer, we have the report server—a perfect marriage between a Windows service and a web service. Web Service The web service provides a set of programmatic interfaces that allow communication with the report server. It is required for on-demand delivery and for the use of client tools like Report Manager, Report Builder, or SQL Server Management Studio. Windows Service The Windows service is responsible for scheduling and delivery services, server maintenance, encryption operations, and initialization services. It is required for the push delivery method of reports. For scheduling operations, the SQL Server Agent Service is required. If you need just push delivery reporting, you can run only the Report Server Windows service. However, you will have available just a part of the Reporting Services functionality. Programming Interfaces Applications can use Simple Object Access Protocol (SOAP), URL endpoints, and Windows Management Instrumentation (WMI) to talk to report servers. If you are not familiar with web services, they simply allow you to use programmatic functionality (functions, procedures, T-SQL stored procedures, etc.) over the web, by including the call to the functionality in your request to the web server and the result of the call in the web server’s response. The communication protocol used by web services is SOAP. SOAP messages have a simple XML form. I captured the SOAP message used by Business Intelligence Development Studio to deploy a report. You can see that it is not so complicated. A report named ContactList is created in a parent folder named Advance Report. The existing report, if any, will be overwritten. <?xml version="1.0" encoding="utf-8" ?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <CreateReport xmlns="http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/ reportingservices"> <Report>ContactList</Report> <Parent>/Advanced Report</Parent> <Overwrite>true</Overwrite> <Definition> </Definition> </CreateReport> </soap:Body> </soap:Envelope> Dewson_5882C14.fm Page 456 Tuesday, January 10, 2006 2:35 PM CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES 457 The importance of SOAP is that anyone can talk SOAP, which is XML. To receive SOAP messages, the Reporting Services web service uses URL endpoints, to which you send your requests to work with reports. SQL Server 2005 Reporting Services comes with two new endpoints—for report execution and for report management. You can use both of them to build custom tools, though most likely you will be just happy with the existing set of tools. Processors The only components of Reporting Services that cannot be extended are the Report Processor and the Scheduling and Delivery Processor. The first one is responsible for combining a report layout with data and rendering a report in a requested format. The Scheduling and Delivery Processor is responsible for delivering reports and supports scheduled operations. Extensions One of the main qualities of Reporting Services is extensibility. You can add custom extensions for authentication, data processing, report processing, rendering, and delivery. Authentication Extensions Reporting Services uses a role-based security model in which users and groups are mapped to roles. Roles are just a collection of tasks that can be performed. For example, the Report Builder Role allows a user to build and edit reports with Report Builder. You can also define your own custom roles. The default authentication uses Internet Information Services (IIS) to authenti- cate Windows users and groups. You can use a custom authentication extension to get users from other directory services like Novell Directory Services, for example. Data Processing Extensions Data processing extensions are used to get data from various sources like SQL Server, Analysis Services, Oracle, OLE DB, and ODBC data sources. Rendering Extensions Rendering extensions work with Report Processor to transform the data and the report layout into a specific format. Available are the following rendering extensions: HTML (to generate HTML using UTF-8 encoding), Excel (to generate reports in a native file format for Excel—Binary Interchange File Format), CSV (to generate Comma-Separated Value files), Image (to generate image formats like BMP, GIF, JPEG, TIFF, EMF, WMF), PDF, and XML. Report Processing Extensions If you need custom report items, you can add new report processing extensions for them. Delivery Extensions The delivery extensions are used by the Scheduling and Delivery Processor to deliver reports to locations such as e-mails or file shares. You can even send short notices (not the actual report) to mobile devices like pagers and phones. Dewson_5882C14.fm Page 457 Tuesday, January 10, 2006 2:35 PM 458 CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES The Data Layer At the data layer level, we have two SQL Server databases and a lot of options for data sources. Report Server Databases SQL Server 2005 Reporting Services uses two SQL Server databases (ReportServer, ReportServerTempDB) to store the information used by the report server. The ReportServer database stores static metadata such as report definitions, data sources, users, roles, subscrip- tions, and schedule definitions. The ReportServerTempDB database stores temporary objects such as work tables or session data. To store Reporting Services databases, you can use another server and even another version of SQL Server (SQL Server 2000). Data Sources The report data sources can come from SQL Server, Analysis Services, Excel, Access, Oracle, flat files or any OLE DB, and ODBC data sources. Using data processing extensions, you can add new sources of data. Building Your First Report Using Report Wizard In this section, we will call the Report Wizard—the perfect tool for a beginner or for an urgent situation. The end result will be a simple report containing the list of contacts from the CustomerDetails.Customers table. Try It Out: Using the Report Wizard 1. From the Start menu, select Programs ➤ Microsoft SQL Server 2005 ➤ SQL Server Business Intelli- gence Development Studio. 2. Once Business Intelligence Development Studio has opened, on the File menu, select New ➤ Project. 3. In the Project Types list, click Business Intelligence Projects. 4. In the Templates list, click Report Server Project Wizard. 5. Type ApressFinancial Reports in the name textbox as shown in Figure 14-2 and leave the default location as it is. Click OK to start the Report Wizard. 6. On the Welcome page of the wizard, you will see a short description of the wizard. You may read it and then click Next. 7. On the Select the Data Source page, make sure that Microsoft SQL Server is selected in the Type drop-down list. Dewson_5882C14.fm Page 458 Tuesday, January 10, 2006 2:35 PM CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES 459 Figure 14-2. Selecting the report template and report name 8. This step defines the source of data for our report. We will use the ApressFinancial database from our local server. Use the Edit button to open the Connection Properties dialog box and specify XP-PRO for Server Name and ApressFinancial in Select or Enter a Database Name as shown in the following screenshot. Dewson_5882C14.fm Page 459 Tuesday, January 10, 2006 2:35 PM 460 CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES An alternative is to remain in the Data Source page and type Data source= XP-PRO; Initial Catalog= ApressFinancial in the Connection String textbox as you see in Figure 14-3. Click Next. Figure 14-3. Define the data source ■Tip Remember to change the Data source to the SQL Server instance you are connecting to, such as (local). 9. In the Design the Query page, shown in Figure 14-4, you can use the Query Designer to build your query. This example is very simple, so just use the Query string text box to enter the following SELECT statement and click Next: SELECT CustomerFirstName, CustomerLastName FROM CustomerDetails.Customers 10. The next step is to select a report type. Select Tabular and click Next. 11. To make the report really simple, I will not use any kind of grouping. In the Design the Table page, shown in Figure 14-5, you can select fields by which to group or fields to display in the Report Details section. Select the CustomerFirstName and CustomerLastName fields and click the Details button to add them to the details section. Click Next. Dewson_5882C14.fm Page 460 Tuesday, January 10, 2006 2:35 PM CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES 461 Figure 14-4. Design the Query window Figure 14-5. Design the Table window Dewson_5882C14.fm Page 461 Tuesday, January 10, 2006 2:35 PM 462 CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES 12. The Choose the Table Style page allows you to apply a style to the report by selecting a style template. I prefer the style template named Corporate. Select one template and click Next. 13. The next page, Choose the Deployment Location, allows you to configure the report server and the folder to which the report will be published. The Report Wizard will not publish the report. You can do that yourself later on. 14. The last step gives you a last chance to verify the information entered. You have the option to rename the report, but for this demo leave the default name—Report1. Select the Preview Report check box to preview the report as soon as the wizard finishes. Click Finish. Congratulations! You just did your first report. If you did everything just right, you should see the preview of your report, which should resemble Figure 14-6. Figure 14-6. The preview of your report You can see the two columns selected in step 11, the tabular format of data because of the choice you selected in step 10, and of course, the great name Report1 that you can change if you choose to. In the next section, I will tell you about various report items. Building a Report from Scratch In this section, you will learn to build a report without the help of Report Wizard. That means that you will have to define a data source and build a design for your report. Once the report is built, I will show you how to add some interactivity by using parameters. Before we do the actual demo, let’s take a closer look at some of the elements we can use. Dewson_5882C14.fm Page 462 Tuesday, January 10, 2006 2:35 PM CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES 463 Data-Related Elements The utility of a report is given mainly by its data. In order to have data in a report, you have to define at least a data source and a dataset. The data view of the graphical designer interface allows you to create datasets and data sources. Data Source A data source represents the necessary information to get to the source of data. Such informa- tion may include a server name, a database name, and user credentials. The information included depends on the source of data, for example, if you use a text file, you will specify the path to the text file and not a server name or a database name. A report can use multiple data sources. There are two types of data sources: shared (can be used by multiple reports) or report specific (used by a particular report). Another difference between shared and report-specific data sources is their storage location. A shared data source is stored in a separate file on the report server, while the report-specific data source is stored in the report definition. Dataset Once we have defined the source of data, we will create a dataset using a query. You can imagine a dataset as a set of rows with data. I would mention that a report can also have multiple datasets. Fields Every row of a dataset has one or more fields that typically refer to columns returned by the query that populated the dataset. You can find all fields of a dataset in the Fields window. Using the drag-and-drop method, you can include any field in your report. Custom fields Besides the existing fields of a dataset, you can create new ones using several methods. You can create calculated fields based on existing fields, or you can use aggregate functions such as Sum, Avg, and Count. Report Items There are two types of report items: data regions and independent items. Data Regions Data regions display data from datasets, with each data region being associated to one dataset. You can use the following types of data regions: • Table: A table is a data region that uses static columns and rows to display data. • Matrix: A matrix (or crosstab) is a more complex data region having columns and rows that can contain other columns or rows. Dewson_5882C14.fm Page 463 Tuesday, January 10, 2006 2:35 PM [...]... January 10, 2006 2:35 PM 466 CHAPTER 14 ■ SQL SERVER 2005 REPORTING SERVICES 11 Click OK to add the ApressFinancial dataset 12 Type the following query into the SQL pane that opened: SELECT C.CustomerFirstName, C.CustomerLastName, T.TitleDescription FROM CustomerDetails.Customers C JOIN CustomerDetails.Title T ON C.CustomerTitleId = T.CustomerTitleId 13 Click the Run (!) button on the Query Designer toolbar... retrieve data from objects within SQL Server or any other database that supports SQL, for example, Oracle or Sybase Dewson_5882AppA.fm Page 481 Thursday, January 12, 2006 7:05 AM APPENDIX ■ GLOSSARY OF TERMS SQL Server authentication A method for validating login attempts to SQL Server using a user ID and password that are defined with SQL Server stored procedure A set of T -SQL statements grouped together... of any connections to the database Windows authentication uses the Windows user ID and logon as the basis of its connection to SQL Server This is more secure than SQL Server authentication for connecting to SQL Server X XML Short for eXtensible Markup Language, this is a technique for building self-describing data This can be used to pass data and information between systems or to a web browser Data... 18–19 T -SQL commands, 196–199 Auto List Members, SSMS, 38 verification, 189–190 AUTO_CLOSE, T -SQL, 87 batch, defined, 474 AUTO_CREATE_STATISTICS, T -SQL, 87 batch insertions, 262 AUTO_SHRINK, T -SQL, 87 Batch Separator option, SSMS, 41 AUTO_UPDATE_STATISTICS, T -SQL, 87 BEGIN END blocks, stored procedures, 339, 349–350 AUTO_UPDATE_STATISTICS_ASYNC, T -SQL, 88 BEGIN TRAN command, transactions, 298 autorun.exe,... ■ SQL SERVER 2005 REPORTING SERVICES SELECT TitleDescription FROM CustomerDetails.Title 16 Click OK to add the TitleList dataset Optionally, you can click the Run (!) button on the Query Designer toolbar to see the results of the query In this section, we will add a table data region to the report layout 17 Click the Layout tab to display the Layout view 18 If the Toolbox window is not displayed, from. .. refer to a file on the same computer, or another server if required batch A set of T -SQL statements forming one group, or batch, of actions In Query Editor, you define the end of a batch by employing a GO statement, or another statement set via options within Query Editor A batch allows you to put together a set of work that either has to be a batch because of the way SQL Server works, or you wish to. .. transaction changes from memory to disk clustered index An index on a table (or view) that defines the physical order in which the data will be stored on the table (or view) COMMIT TRAN[SACTION] Used to inform SQL Server that any data modifications performed within a transaction, by using the BEGIN TRAN[SACTION] statement , are to be accepted as being valid and are to be committed to the database (that... to the end of Beginning SQL Server 2005 Programming, demonstrating how to report on the data within the example we have been building up throughout the book There has been an overview of how reporting services works and is architected, and we have seen an overview of building a simple report and previewing the results The next move for you would be to read Pro SQL Server 2005 (Apress, 2005; ISBN 1590594770)... this refers to the process of verifying that the submitted user ID is valid for a given instance of SQL Server, and then allocating permissions to that user based upon his or her user profile B backup device Describes a hardware device such as a tape drive used to back up a SQL Server database If a tape drive is used, then the tape drive must be attached directly to the computer that the SQL Server database... (Surface Area Configuration tool), 50 ALTER TRIGGER command, T -SQL, 435–436 alternatives to SQL Server, 2 ADD CONSTRAINT command, T -SQL, 150, 256, 261 American National Standards Institute (ANSI), defined, 473 administrator account, 96 Analysis Services, 10 administrator rights, 19, 22 ANSI (American National Standards Institute), defined, 473 Administrators group in Windows, 106 AdventureWorks/AdventureWorksDW . two SQL Server databases and a lot of options for data sources. Report Server Databases SQL Server 2005 Reporting Services uses two SQL Server databases (ReportServer, ReportServerTempDB) to store. previewing the results. The next move for you would be to read Pro SQL Server 2005 (Apress, 2005; ISBN 1590594770) and also Pro SQL Server 2005 Assemblies (Apress, 2005; ISBN 1590595661). Dewson_5882C14.fm. T.TitleDescription FROM CustomerDetails.Customers C JOIN CustomerDetails.Title T ON C.CustomerTitleId = T.CustomerTitleId 13. Click the Run (!) button on the Query Designer toolbar to see the results

Ngày đăng: 14/08/2014, 10:22

Từ khóa liên quan

Mục lục

  • Beginning SQL Server 2005 for Developers

    • Appendix A Glossary of Terms

    • Index

Tài liệu cùng người dùng

Tài liệu liên quan