System Center Configuration Manager Team Blog Download Article SQL Reporting Services – Tools and Features Part 1: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 Microsoft Corporation Published: March 2009 System Center Configuration Manager Team Blog Author Bhaskar Krishnan, Software Development Engineer in Test for the System Center Configuration Manager product group Feedback Send suggestions and comments about this document to cmtblog@microsoft.com. Please include the document name with your feedback. This information that Microsoft provides to you is subject to the following Terms of Use ("TOU") http://www.microsoft.com/info/cpyright.mspx. Microsoft reserves the right to update the TOU at any time without notice to you. This document is provided AS IS without warranty of any kind. Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted in examples herein are fictitious. No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. 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. © 2009 Microsoft Corporation. All rights reserved. Revision History Release Date Changes March, 2009 Original release of this document System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 Overview There are various tools available to create SQL Reporting Services reports. You can create Configuration Manager 2007 R2 reports using any of the following tools: 1) SQL Reporting Services 2008 Report Builder 2.0 – This is a standalone tool that can be downloaded for free from here: http://www.microsoft.com/downloads/details.aspx?FamilyID=9f783224-9871-4eeab1d5-f3140a253db6&displaylang=en 2) SQL Server Business Intelligence Development Studio – Visual Studio environment for creating reporting projects. This is included in the SQL Server 2008 installation package. 3) Using the SQL based report Wizard that shipped in Configuration Manager 2007 R2 release. 1) and 2) above are more robust tools for creating powerful reports and this post specifically covers Report Builder 2.0 which was released recently and provides some rich report authoring functionality against SQL Server 2008 Reporting Services. How to use SQL Reporting Services Report Builder 2.0 For this post, we’ll create a sample Configuration Manager report that lists all advertisements for a specific collection. Before authoring the report, we’ll draft the rough requirements for this report: Step 1) Requirements 1) Input: a) The report requires an input parameter, which is CollectionID. b) In addition we want the users to select the Collection ID from a list of available collections. We basically need a SQL query for retrieving the list of available collections in the site server. The query that would accomplish this would look something as follows: SELECT DISTINCT CollectionID, Name FROM v_Collection ORDER BY Name where v_Collection is a view in the Configuration Manager database that can be used to return all the collections in the site server. 2) Output: a) We would like the report to display all the advertisements for that collection grouped by manufacturer. So here is what we want to display: i. Manufacturer ii. Package Name iii. Source Site iv. Advertisement ID v. Advertisment Name vi. Comment System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 The advertisement and package information can be retrieved from the v_Advertisement and v_Package views in the Configuration Manager database. The query to do this would look something as follows: SELECT v_Package.Name ,v_Package.Manufacturer ,v_Package.SourceSite ,v_Advertisement.AdvertisementID ,v_Advertisement.AdvertisementName ,v_Advertisement.ProgramName ,v_Advertisement.Comment FROM v_Package INNER JOIN v_Advertisement ON v_Advertisement.PackageID WHERE v_Advertisement.CollectionID = @ID v_Package.PackageID = where @ID is the report input parameter for the CollectionID. Note that we mentioned that we would like to view the results grouped by Manufacturer. This requirement is not captured in the SQL query above but rather we will capture as part of the report formatting experience in Report Builder 2.0, which provides a flexible way to group and sort results. Step 2) Install SQL Reporting Services 2008 Report Builder 2.0 1) Download SQL Reporting Services 2008 Report Builder 2.0 using the link below: http://www.microsoft.com/downloads/details.aspx?FamilyID=9f783224-9871-4eea-b1d5f3140a253db6&displaylang=en 2) The installation process of Report Builder 2.0 is pretty straight-forward but the one thing I would like to mention is that the installation process asks for the Report Server url. You can specify the report server url as follows: For default instances: http://[ReportServerMachineName]/ReportServer where [ReportServerMachineName] is the name of the server on which Reporting Services 2008 is installed. For named instances: http://[ReportServerMachineName]/ReportServer_[InstanceName] where [InstanceName] is the name of the report server instance. For SSL enabled report servers, the above urls become https:// urls System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 The reason the installation asks for a report server url is to facilitate editing and saving reports directly to the report server. Step 3) Author the report using SQL Reporting Services Report Builder 2.0 1) Start Report Builder 2.0 from Start->Programs->Microsoft SQL Server 2008 Report Builder 2.0 2) Configure the data source 1. Every report requires a data source from where the report data is retrieved. 2. When Report Builder 2.0 starts it connects to the report server specified in Step 2) above. 3. Once Report Builder is open, click on New (show below) and select Data Source There are two options for specifying a data source: a) Use a shared connection or report model or b) Use a connection embedded in my report If you want to use the shared data source that is already created as part of the Copy Reports Wizard in Configuration Manager R2 use 4) below to create a shared data source else skip to 5) to create an embedded data source within the report itself. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 4. Using shared connection: In this case you have the option of specifying an existing configured data source. For example, if you have the reporting services role configured with Configuration Manager 2007 R2 and all the reports are already deployed to the report server, then you can directly leverage the data source that is already created for the Configuration Manager database. The data source object can be located directly under the configured root report folder for the site and should read {5C6358F2-4BB6-4a1b-A16E-8D96795D8602}. The steps below walk through the wizard to point to an existing data source. a) In the Data Source Properties window, select the option for “Use a shared connection or report model” b) Click Browse to locate the data source. c) The browse dialog window will connect to the report server configured during the installation of report builder and present the view of the root folder on the report server as follows (note that the machine name in the http:// url has been blanked out intentionally): System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 d) Click the root folder that was used to configure the reporting services site role. In the above case, ConfigMgr_UV4 is the report folder – so double click that folder to view the contents of that folder e) Double click the GUID type object “{5C6358F2-4BB6-4a1b-A16E8D96795D8602}” and click Open to accept that data source. f) The data source properties window should look like the screenshot below. Click OK to save the data source which can then be used to create data sets for the report. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 5. Using a connection embedded in the report: a) In the Data Source Properties window, select the option for “Use a connection embedded in my report” b) Leave the connection type as “Microsoft SQL Server” c) Click Build to build a connection string to the data source. In this case the data source is going to be the Configuration Manager database. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 Note: If your report retrieves data from multiple databases, you can provide specific names to the data source as a best practice to identify which data source points to which source database. In the above case the default name is “DataSource1”. You can change it to say “SMSDataSource” System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 d) Enter the SQL Server name hosting the Configuration Manager database and specify the Configuration Manager database name as shown above (you can also test the connectivity to the database) and click OK. The connection string should get populated in the Data Source Properties window. e) Click OK on the Data Source Properties window to save the data source. This should now appear as “DataSource1” under Report Data. 3) Configure the data set for report input parameter CollectionID a) A dataset holds the results of any query that needs to be run as part of the report. In this report, we need to present the user with a list of Collection IDs from which the user can make a selection. We already know the query that would return us the list of Collection IDs. So let us go ahead and create a dataset with the query we specified earlier. b) Click “Dataset…” from New-> Dataset… c) On the Dataset properties window, specify the name for the dataset as “CollectionID” and select the data source as “DataSource1” since the collection IDs need to be retrieved from the Configuration Manager database. d) Copy and paste the following query into the Query text box SELECT DISTINCT CollectionID, Name FROM v_Collection ORDER BY Name System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 Click OK to save the dataset. The dataset “CollectionID” should now appear under the DataSource1 4) Configure the dataset for retrieving the report content a) Follow the same steps as in 3) above to create another dataset. Name the dataset as “Advertisements” and copy paste the query we wrote in Step 1) in the query text box. b) Click OK to save the dataset. c) Note that since the query contains a parameter reference “@ID” you will notice that Report Builder identifies it as a report parameter automatically and creates a parameter with the same name. You can find this under “Parameters” 5) Configure the report parameter ID to bind to the CollectionID dataset a) Since we want the user to select from a list of Collection IDs, we need to bind the report parameter automatically created in 4) to the CollectionID dataset created in 3). b) Expand the Parameters node, right click the parameter “ID” and open the Parameter Properties window. c) Accept the defaults on the General page d) Click on “Available Values” and select the option for “Get values from a query”. Select the dataset “CollectionID” from the dropdown list. There are two other options for specifying Value field and Name field. The value field is the value that you want to pass on to the report dataset query that retrieves the list of advertisements. Since our query requires CollectionID, select CollectionID from the drop-down list for Value field. The name field is what gets displayed to the user. Note that our query for retrieving collections returns both the collection name as well as the ID but most often users aren’t familiar with all the CollectionIDs but are more familiar with the user friendly collection names. In this case, we want the users to identify the collections by their friendly names rather than their IDs. So select Name from the drop-down list for Name field. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 e) Click OK to save the changes for the report parameter. 6) Add the table to the report to display the report content a) Now that we have everything configured for the report itself it is time to put the display in place. b) On the main window, double click the icon for “Table or matrix” to launch the table wizard c) On the “Choose a dataset” page select the “Advertisements” dataset and click Next. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 d) On the New Table or Matrix page, click the Manufacturer field under the list of Available fields and drag/drop it on the Row groups window as shown below. Similarly, select each one of the other fields from the Available fields list and drag/drop them onto the Values window. The above basically means that we want to group the rows based on Manufacturer and the list of fields appearing in the “Values” window would be the ones displayed on the report. You can rearrange the order in which the fields System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 appear on the report by simply clicking and dragging them up and down Values pane. Click Next to proceed to report layout. e) On the layout page, select the way you want to display the report data. In case, I prefer the second option “Blocked, subtotal above” and I want ability to expand/collapse groups. So I have checked the box “Expand/collapse groups”. Click Next to proceed to the Style page. the this the for f) On the style page, click any of the available styles. In this case I decided to go with the “Corporate” style. Click Finish to complete the wizard. g) On the main window you should now see the report skeleton. Click “Click to add title” and give the report an appropriate title like “Software Advertisements”. Note that you can even add expressions that can be evaluated at runtime to make the report title dynamic. For example, I could write the title as “Software Advertisements for “ and then right click and select “Create Placeholder”. Using the “Create Placeholder” wizard I put in an expression to specify the value of the CollectionID at the end of the title so that when the report runs, the report title would read Software Advertisements for [CollectionX]”. That is indeed pretty nifty. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 h) Optionally you may want to change the column header names to be more meaningful/user friendly. You can edit the column headers directly by clicking the respective column header and editing it. Also adjust the width of each column appropriately depending on your needs. 7) Save the report – Report Builder allows you to save the report directly to the target report server. 8) Run the report and verify the contents a) You can run the report directly from Report Builder using the Run option and verify if the report runs correctly and displays the correct data in the correct format. b) Once you have saved the report to the report server you can run the report from SQL Reporting Services 2008 Web Report manager. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 Additional functionalities in Report Builder 2.0 1. Easier ways to author charts The screenshot below shows a simple bar chart that displays the count of installed software grouped by manufacturer where the count > 1. Charts like the one below present a very high level and concise view to upper management on which software vendor is most being utilized within a particular organization or department. In this case, the collection could model a department or business unit within the organization and present a concise view of which software vendor is being utilized the most within each department or business unit. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 The above chart derives its data from the following SQL query: SELECT COUNT(*) AS SoftwareCount, v_Package.Manufacturer FROM v_Package INNER JOIN v_Advertisement ON v_Package.PackageID v_Advertisement.PackageID WHERE v_Advertisement.CollectionID = @ID GROUP BY v_Package.Manufacturer HAVING COUNT(*) > 1 = Steps to create the above chart: a) Add a dataset to the report called “CountOfSoftware” using the steps outlined earlier in this tutorial. The query for the dataset appears above - simply copy and paste the query into the dataset. b) Right click the main report window and select Insert -> Chart. This opens a window to select a chart type as shown below: System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 c) In this case, I selected the first Column chart for the sample report above and clicked OK. This creates a template chart as shown below in the main window. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 d) Double click the space that reads “Chart Title” and change the title to “Count of Software”. e) Double click the chart to bring up the options to specify the data for the chart. See below for a sample screenshot. For this report we are plotting the count of software on the Y-axis and the manufacturers on the X-axis. The screenshot below illustrates how to select the Manufacturers for the X-axis (the chart direction reads “Drop category fields here”). For the Y-axis, where the chart says “Drop data fields here”, select “SoftwareCount”. System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 f) Double click “Axis Title” and change the title to set meaningful values for the X and Y-axes respectively. Having done this, the chart should look something like the the following: System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights. System Center Configuration Manager Team Blog Download Article: Creating Configuration Manager 2007 Reports Using Report Builder 2.0 g) The report along with the chart is ready for deployment and execution. Click Run in Report Builder to run the report - the chart should appear at the end of the report content. 2. Use of dynamic expressions in reports The ability to use expressions renders a great deal of dynamism to the reports. There are quite a few examples listed here: http://msdn.microsoft.com/en-us/library/dd283099.aspx#ReportFunctions Check out some of the examples on how to dynamically change color for each row in the report and make the report a lot more appealing to the eye. 3. Sorting and grouping report data Sorting and grouping of data within a report can be accomplished at runtime without the need to specify group/sort clauses in any SQL queries. In addition, individual report columns can be appended with sorting icons to allow users to sort the column at runtime. To conclude, if I haven’t convinced you to try out SQL Reporting Services and Report Builder please look ahead for Part 2 of this post where I will illustrate data-driven subscriptions and how they extend report delivery to the next level. If you have any questions on authoring Configuration Manager reports in Report Builder please leave your comments on this post and I will address them as soon as possible. --Bhaskar Krishnan System Center Configuration Manager Team Blog: Provided "AS IS" with no warranties, and confers no rights.