ptg 2164 CHAPTER 52 SQL Server Integration Services Generally, you get at least a 50% drop in transfer speed if the table has an index. The more indexes, the greater the performance degradation. This is due to the logging factor: more log records are being generated, and index pages are being loaded into the cache and modified. This can also cause the log to grow, possibly filling it (depending on the log file settings). NOTE Despite the name, even a nonlogged operation logs some things. In the case of index- es, index page changes and allocations are logged, but the main area of logging is of extent allocations every time the table is extended for additional storage space for the new rows. Batches By default, bcp puts all the rows that are inserted into the target table into a single trans- action. bcp calls this a batch. This arrangement reduces the amount of work the log must deal with; however, it locks down the transaction log by keeping a large part of it active, which can make truncating or backing up the transaction log impossible or unproductive. By using the bcp batch (–b) switch, you can control the number of rows in each batch (or, effectively, each transaction). This switch controls the frequency of commits; although it can increase the activity in the log, it enables you to trim the size of the transaction log. You should tune the batch size in relation to the size of the data rows, transaction log size, and total number of rows to be loaded. The value you use for one load might not neces- sarily be the right value for all other loads. Note that if a subsequent batch fails, the prior batches are committed, and those rows become part of the table. However, any rows copied up to the point of failure in the failing batch are rolled back. Parallel Loading A great enhancement of bcp is that you can now use it to do parallel loads of tables. If you want to take advantage of this feature, the following must be true: . The bulk-copy operation must be nonlogged; all requirements specified in the previ- ous discussion on nonlogged operations must be met. . There must be no indexes on the target table. Only applications using the ODBC or SQL OLE DB–based APIs can perform parallel data loads into a single table. The procedure is straightforward. After you ascertain that the target table has no indexes (which could involve dropping primary or unique constraints) and is not being replicated, you must set the database option SELECT INTO/BULK COPY to true. The requirement to drop all indexes has to do with the locking that must occur to load the data. Although the table itself can have a shared lock, the index pages are an area of contention that prevents parallel access. ptg 2165 Logged and Nonlogged Operations 52 Now all that is required is to set up the parallel bcp loads to load the data into the table. You can use the –F and –L switches to specify the range of the data you want each parallel bcp to load into the table if you are using the same data file. Using these switches removes the need to manually break up the file. Here is an example of the command switches involved for a parallel load with bcp for the customers table: bcp AdventureWorks2008.Sales.SalesOrderHeader IN SalesOrders10000.dat –T –S servername –c –F 1 –L 10000 –h “TABLOCK” bcp AdventureWorks2008.Sales.SalesOrderHeader IN SalesOrders20000.dat –T –S servername –c –F 10001 –L 20000 –h “TABLOCK” The TABLOCK hint (–h switch) provides improved performance by removing contention from other users while the load takes place. If you do not use the hint, the load takes place using row-level locks, and this is considerably slower. SQL Server 2008 allows parallel loads without affecting performance by making each bcp connection create extents in nonoverlapping ranges. The ranges are then linked into the table’s page chain. After the table is loaded, it is also possible to create multiple nonclustered indexes in parallel. If there is a clustered index, you work with that one first, followed by the paral- lel nonclustered index. Supplying Hints to bcp The SQL Server 2008 version of bcp enables you to further control the speed of data loading, to invoke constraints, and to have insert triggers fired during loads. To take advantage of these capabilities, you use hint switches to specify one or more hints at a time. Following is the syntax: –h “hint [, hint]” This option cannot be used when bulk-copying data into versions of SQL Server before version 7.0 because, starting with SQL Server 7.0, bcp works in conjunction with the query processor. The query processor optimizes data loads and unloads for OLE database rowsets that the latest versions of bcp and BULK INSERT can generate. The following sections describe the various hints you can specify with the –h switch. The ROWS_PER_BATCH Hint The ROWS_PER_BATCH hint is used to tell SQL Server the total number of rows in the data file. This hint helps SQL Server optimize the entire load operation. This hint and the –b switch heavily influence the logging operations that occur with data inserts. If you specify both this hint and the –b switch, they must have the same values, or you get an error message. ptg 2166 CHAPTER 52 SQL Server Integration Services When you use the ROWS_PER_BATCH hint, you copy the entire result set as a single transac- tion. SQL Server automatically optimizes the load operation, using the batch size you specify. The value you specify does not have to be accurate, but you should be aware of the practical limit, based on the database’s transaction log. TIP Do not be confused by the name of the ROWS_PER_BATCH hint. You are specifying the total file size and not the batch size (as is the case with the –b switch). The CHECK_CONSTRAINTS Hint The CHECK_CONSTRAINTS hint controls whether check constraints are executed as part of the bcp operation. With bcp, the default is that check constraints are not executed. This hint option allows you to turn the feature on (to have check constraints executed for each insert). If you do not use this option, you should either be very sure of your data or rerun the same logic as in the check constraints you deferred after the data has been loaded. The FIRE_TRIGGER Hint The FIRE_TRIGGER hint controls whether the insert trigger on the target table is executed as part of the bcp operation. With bcp, the default is that no triggers are executed. This hint option allows you to turn the feature on (to have insert triggers executed for each insert). As you can imagine, when this option is used, it slows down the bcp load opera- tion. However, the business reasons to have the insert trigger fired might outweigh the slower loading. The ORDER Hint If the data you want to load is already in the same sequence as the clustered index on the receiving table, you can use the ORDER hint. The syntax for this hint is as follows: ORDER( {column [ASC | DESC] [, n]}) There must be a clustered index on the same columns, in the same key sequence as speci- fied in the ORDER hint. Using a sorted data file (in the same order as the clustering index) helps SQL Server place the data into the table with minimal overhead. The KILOBYTES_PER_BATCH Hint The KILOBYTES_PER_BATCH hint gives the size, in kilobytes, of the data in each batch. This is an estimate that SQL Server uses internally to optimize the data load and logging areas of the bcp operation. The TABLOCK Hint The TABLOCK hint is used to place a table-level lock for the bcp load duration. This hint gives you increased performance at a loss of concurrency, as described in the section “Parallel Loading,” earlier in this chapter. ptg 2167 Summary 52 Summary It is fairly easy to create and implement a typical data export, data import, or complex data transformation by using SSIS. You can either use the wizard for basic data transforma- tion needs or the SSIS Designer for massively complex transformations (which may have multiple data sources and/or multiple data destinations). This very robust environment has adopted a very formal, managed code rigor. With the SSIS capabilities, you get a self- contained place to build these data transformation solutions, and you can do so very rapidly. SSIS is completely integrated into the Visual Studio/BI Development Studio envi- ronment as well, making it that much easier to start producing rock-solid implementa- tions. And, with Change Data Capture for SSIS, a new dimension of trickling data changes to various platforms becomes available with SSIS processing. This chapter also shows how to bulk-load data into and out of SQL Server by using the bcp utility. The multitude of switches bcp offers are very comprehensive and address most, if not all, importing and exporting situations. More importantly, with the advent of some additional switches, such as ORDER (within hints), TABLOCK (within hints), batches (–b), network packet sizes ( –a), and others, it is significantly easier to increase the performance of bcp in a big way. bcp has been around for a long time, and it will continue to be the workhorse of bulk data loading and unloading. Chapter 53, “SQL Server 2008 Reporting Services” discusses this significant SQL Server capability and how to maximize its use for a production environment. ptg This page intentionally left blank ptg CHAPTER 53 SQL Server 2008 Reporting Services IN THIS CHAPTER . What’s New in SSRS 2008 . Reporting Services Architecture . Installing and Configuring SSRS . Developing Reports . Management and Security . Performance and Monitoring This chapter introduces SQL Server Reporting Services 2008 (SSRS). It provides an overview of the product’s features and architecture, covers the most important func- tional areas, and gives examples of how to get started devel- oping on the platform. Although this chapter is by no means a comprehensive description of everything in SSRS, its purpose is to get you excited about the capabilities of this potent technology. SSRS is an enterprise-class reporting platform that provides all the tools and services needed to support data-driven reporting. SSRS empowers you to design reports using a variety of advanced data visualization controls; populate them with data culled from a variety of sources; deploy, secure access to, and schedule execution of reports; and deliver them to the Web, SharePoint, email recipients, file shares, and more, on a scheduled or on-demand basis. The first version of SSRS shipped in January 2004 as part of SQL Server 2000, generating enthusiasm and enjoying rapid adoption, as did the enhancements that came in the SQL Server 2005 release. The latest version of SSRS, included with SQL Server 2008, comes with a bevy of enhancements geared toward better performance, increased interoperabil- ity, consolidation of tools and services, reductions in depen- dencies, improved user experience, finer control over design, and overall ease of use. What’s New in SSRS 2008 From design to architecture, SSRS 2008 includes a number of platform changes across all areas of the product. The list ptg 2170 CHAPTER 53 SQL Server 2008 Reporting Services is long, but it should be duly noted because some of these changes may have a significant impact on your design, development, monitoring, and tuning processes. In the following sections, we cover all the features that have been discontinued and any changes that could break your existing applications. After that, we detail all the enhance- ments included in this release. Be forewarned: it’s a lot of ground to cover in a short space, so the pace is quick. Discontinued Functionality and Breaking Changes With SSRS 2008, a number of features have been discontinued or significantly changed. They include . SSRS 2008 no longer relies on Internet Information Services (IIS) at all. This means there are no IIS-based websites used by the platform in this release. To process HTTP requests for SSRS web services, Report Manager ASPX pages, and other calls, SSRS 2008 now natively hosts the .NET Framework and ASP.NET. SSRS ties directly in with operating-system–level (or kernel-mode) HTTP, listening for requests by way of the HTTP API (sometimes referred to as http.sys). This means that under the covers, SSRS registers its virtual paths (also known as URIs, for example, www.myserver.com/Reports) with http.sys in the same way that IIS would register a virtual directory. The operating system redirects incoming HTTP requests to IIS or SSRS, based on the path specified in the request. Be aware that any ISAPI extensions, virtual directory settings, or other advanced Web customizations you may have built might not be compatible with the new SSRS HTTP architecture. . Because of the HTTP architecture changes in SSRS 2008, a few HTTP port-related concerns are noteworthy: . When you are installing SSRS 2008 on 32-bit Windows XP, SSRS reserves port 8080 (because IIS 5.1 has already exclusively reserved port 80). . When you are installing SSRS on other operating systems (including 64-bit XP), port 80 is used in the default native configuration. This means that when configuring your SSRS URIs using the Reporting Services Configuration Tool (RSCT), you must be sure to use paths and ports that are not already in use in any IIS site or virtual directory (to avoid unintended collisions). TIP If you try to use a port already reserved by a website or other network service, RSCT usually warns you. However, if that website or server is configured but in the stopped state, RSCT may allow you to use that port. This could cause a resource conflict when that website or service is started. ptg 2171 What’s New in SSRS 2008 53 . Email aliases (when doing report deliveries via email) are no longer supported on Vista or Windows Server 2008. . The SQL Server 2000 Report Server web service endpoint has been removed. . Several trace log files have been removed, including . ReportServerWebApp_[timestamp].log . ReportServer_[timestamp].log . ReportServerService_main_[timestamp].log . Only ReportServerService_[timestamp].log remains, and it is now your one-stop location for studying trace activity. . Web application settings have been consolidated from RSWebApplication.config (now obsolete) into RSReportServer.config. . Support for rendering Internet Explorer 5.5–compatible reports is discontinued. . Support for the HTML 3.2 and Office Web Components (OWC) rendering extensions is discontinued. . The Excel rendering extension no longer automatically generates spreadsheet formu- las from your Report Definition Language (RDL) expressions. . The comma-separated value (CSV) rendering extension no longer attempts to preserve formatting (spacing) according to the report’s appearance. However, it now supports two styles of rendering: default mode, which is optimized for Excel, and compliant mode, which is the standard, format-free CSV you would expect to see rendered. . The SSRS Rendering Object Model itself has changed, and earlier versions are no longer supported. . The capability to automatically upgrade an SSRS database is discontinued (it has been removed from RSCT). . Running Report Builder in .NET’s partial trust mode (which requires verification of managed code and limits the ability to call native code) is discontinued. Report Builder now runs only in full trust mode. In SSRS 2005, two separate URLs were used to start Report Builder in each trust level. With SSRS 2008, the only supported URL is now the full trust URL, which is http://[server-name]/[path-to-report- server]/ReportBuilder/ReportBuilder[version].application. . In RDL, object names are now limited to 256 characters in length. . In report rendering, overlapping data regions, repeating items (such as headers and footers), page breaks, and aggregate visibility may be handled differently according to the rendering extension in use. SQL Server Business Intelligence Development Studio (BIDS) warns you upon compilation of your reports if such overlapping occurs. ptg 2172 CHAPTER 53 SQL Server 2008 Reporting Services . The namespace for Report Object Model classes has changed. Microsoft recommends that you reference these classes using only their unqualified (rather than fully quali- fied) names to avoid or resolve this issue in your code. (Note: At compile time, the currently installed version of the SSRS classes is used by default. You can change this by modifying the SpecificVersion attribute in your assembly reference’s properties.) . The SSRS Windows Management Instrumentation (WMI) provider is incompatible with its previous version. This could break scripts you may have written for the rs.exe tool (covered later in this chapter). It also means that, when connecting to an SSRS 2005 instance using SQL Server Management Studio (SSMS), instead of servername\instancename, you must supply the appropriate full SSRS URL. . In SSMS, the Home folder (which formerly provided GUI-based management of all SSRS objects) has been removed. This means you can now use only Report Manager (or, if using SharePoint integration, your site’s SSRS management pages) to manage SSRS content. . In Report Manager, you can no longer manage roles and jobs. SSMS is now the only place for these tasks. . SSRS 2008 is not supported on Windows 2000 servers. Enhancements SSRS 2008 includes a wide range of important enhancements to all aspects of the plat- form. The following sections examine these changes according to functional area. Enhancements in Report Development SSRS 2008 R2 includes a number of enhancements to the suite of tools used in designing, developing, and deploying reports. The following sections detail these enhancements. Enhancements in Report Design The Report Designer, integrated into Visual Studio 2008 (VS; known in SSRS as BIDS) offers a number of improvements. It includes the following upgrades and changes: . Two new subpanes for controlling data grouping: . The Row Grouping pane, which you use to define and manipulate row groups in your reports . The Column Grouping pane, which you use to define and manipulate column groups (when developing matrix-style reports) Both new subpanes include a number of visual cues indicating your current group- ing settings, as well as drop-down boxes that allow you to add, remove, change, and nest data groups, and also define your subtotal and grand total aggregates. ptg 2173 What’s New in SSRS 2008 53 NOTE Control over data grouping was accessible via Property pages in SSRS’s data-bound controls in former versions of BIDS; these new panes make it much easier to access and manipulate your group settings quickly. . The Report Data tab has been removed from the Report Designer. It has been replaced with a new tool window within VS (of the same name) that displays all built-in fields, data sources, datasets (shared and nonshared), report parameters, and images, all in an easy-to-navigate tree. From this tree, most of these objects may be dragged and dropped onto the report design surface. The menu bar located at the top of the Report Data tool window offers commands for creating and editing data sources, datasets, parameters, and images. . The designer surface includes new context-sensitive rulers, a revamped Report Properties dialog, and a simplified context menu. . Using the Report menu (in BIDS), you can now publish report parts to the SSRS catalog (report parts are covered later in this chapter in the section “Using Report Parts”). . You can now create, modify, use, and deploy shared datasets (covered later in this chapter in the section “Using Shared Datasets”). . The Report Designer now supports rotation of text boxes, vertically or horizontally, up to 270°. The Report Designer’s Toolbox tool window offers a number of new data visualization controls: . Tablix—At first glance, the Table, Matrix, and List controls still appear to be the same as in the previous edition of SSRS. However, they have actually been changed to become data region templates, a kind of layout device for the Tablix, a new super- control that embodies all the functionality of the Table, Matrix, and List combined. The Tablix provides functionality for all manner of data grouping; hierarchical nesting of groups; header, footer, and detail row display. Each Tablix cell may contain any other type of Tablix data region or control, enabling an endless variety of layouts. . Gauge—Gauges enable the graphical representation of a single data field or aggre- gate value (sometimes referred to as a key performance indicator or KPI). Each gauge has its own gauge panel, whereupon you may drag and drop additional gauges to display multiple values. Gauges are displayed in either a radial or linear fashion. . Indicator—Actually, a type of small gauge, an indicator enables fast visual compre- hension of a single data field or aggregate value. You may add additional indicators or gauges to an indicator’s gauge panel. When selecting the icons used by your indi- cator, you choose from a small set of predefined images, usually corresponding to . of SQL Server 2000, generating enthusiasm and enjoying rapid adoption, as did the enhancements that came in the SQL Server 2005 release. The latest version of SSRS, included with SQL Server 2008, . Windows Server 2008. . The SQL Server 2000 Report Server web service endpoint has been removed. . Several trace log files have been removed, including . ReportServerWebApp_[timestamp].log . ReportServer_[timestamp].log use. What’s New in SSRS 2008 From design to architecture, SSRS 2008 includes a number of platform changes across all areas of the product. The list ptg 2170 CHAPTER 53 SQL Server 2008 Reporting Services is