2793A-ENU_TrainerWorkbook

393
Course 2793A: Implementing and Maintaining Microsoft® SQL Server™ 2005 Reporting Services

Transcript of 2793A-ENU_TrainerWorkbook

Page 1: 2793A-ENU_TrainerWorkbook

Course 2793A: Implementing and Maintaining Microsoft® SQL Server™ 2005 Reporting Services

Page 2: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

All other trademarks are property of their respective owners.

Product Number: 2793AT

Part Number: X13-70608

Released: 05/2007

Version 1.2

Page 3: 2793A-ENU_TrainerWorkbook

MICROSOFT LICENSE TERMS OFFICIAL MICROSOFT LEARNING PRODUCTS - TRAINER EDITION These license terms are an agreement between Microsoft Corporation and you. Please read them. They apply to the Licensed Content named above, which includes the media on which you received it, if any. The terms also apply to any Microsoft

• updates,

• supplements,

• Internet-based services, and

• support services

for this Licensed Content, unless other terms accompany those items. If so, those terms apply.

By using the Licensed Content, you accept these terms. If you do not accept them, do not use the Licensed Content.

If you comply with these license terms, you have the rights below.

1. DEFINITIONS.

a. “Academic Materials” means the printed or electronic documentation such as manuals, workbooks, white papers, press releases, datasheets, and FAQs which may be included in the Licensed Content.

b. “Authorized Learning Center(s)” means a Microsoft Certified Partner for Learning Solutions location, an IT Academy location, or such other entity as Microsoft may designate from time to time.

c. “Authorized Training Session(s)” means those training sessions authorized by Microsoft and conducted at or through Authorized Learning Centers by a Trainer providing training to Students solely on Official Microsoft Learning Products (formerly known as Microsoft Official Curriculum or “MOC”) and Microsoft Dynamics Learning Products (formerly know as Microsoft Business Solutions Courseware). Each Authorized Training Session will provide training on the subject matter of one (1) Course.

d. “Course” means one of the courses using Licensed Content offered by an Authorized Learning Center during an Authorized Training Session, each of which provides training on a particular Microsoft technology subject matter.

e. “Device(s)” means a single computer, device, workstation, terminal, or other digital electronic or analog device.

f. “Licensed Content” means the materials accompanying these license terms. The Licensed Content may include, but is not limited to, the following elements: (i) Trainer Content, (ii) Student Content, (iii) classroom setup guide, and (iv) Software. There are different and separate components of the Licensed Content for each Course.

g. “Software” means the Virtual Machines and Virtual Hard Disks, or other software applications that may be included with the Licensed Content.

h. “Student(s)” means a student duly enrolled for an Authorized Training Session at your location.

i. “Student Content” means the learning materials accompanying these license terms that are for use by Students and Trainers during an Authorized Training Session. Student Content may include labs, simulations, and courseware files for a Course.

j. “Trainer(s)” means a) a person who is duly certified by Microsoft as a Microsoft Certified Trainer and b) such other individual as authorized in writing by Microsoft and has been engaged by an Authorized Learning Center to teach or instruct an Authorized Training Session to Students on its behalf.

k. “Trainer Content” means the materials accompanying these license terms that are for use by Trainers and Students, as applicable, solely during an Authorized Training Session. Trainer Content

Page 4: 2793A-ENU_TrainerWorkbook

may include Virtual Machines, Virtual Hard Disks, Microsoft PowerPoint files, instructor notes, and demonstration guides and script files for a Course.

l. “Virtual Hard Disks” means Microsoft Software that is comprised of virtualized hard disks (such as a base virtual hard disk or differencing disks) for a Virtual Machine that can be loaded onto a single computer or other device in order to allow end-users to run multiple operating systems concurrently. For the purposes of these license terms, Virtual Hard Disks will be considered “Trainer Content”.

m. “Virtual Machine” means a virtualized computing experience, created and accessed using Microsoft® Virtual PC or Microsoft® Virtual Server software that consists of a virtualized hardware environment, one or more Virtual Hard Disks, and a configuration file setting the parameters of the virtualized hardware environment (e.g., RAM). For the purposes of these license terms, Virtual Hard Disks will be considered “Trainer Content”.

n. “you” means the Authorized Learning Center or Trainer, as applicable, that has agreed to these license terms.

2. OVERVIEW.

Licensed Content. The Licensed Content includes Software, Academic Materials (online and electronic), Trainer Content, Student Content, classroom setup guide, and associated media.

License Model. The Licensed Content is licensed on a per copy per Authorized Learning Center location or per Trainer basis.

3. INSTALLATION AND USE RIGHTS.

a. Authorized Learning Centers and Trainers: For each Authorized Training Session, you may:

i. either install individual copies of the relevant Licensed Content on classroom Devices only for use by Students enrolled in and the Trainer delivering the Authorized Training Session, provided that the number of copies in use does not exceed the number of Students enrolled in and the Trainer delivering the Authorized Training Session, OR

ii. install one copy of the relevant Licensed Content on a network server only for access by classroom Devices and only for use by Students enrolled in and the Trainer delivering the Authorized Training Session, provided that the number of Devices accessing the Licensed Content on such server does not exceed the number of Students enrolled in and the Trainer delivering the Authorized Training Session.

iii. and allow the Students enrolled in and the Trainer delivering the Authorized Training Session to use the Licensed Content that you install in accordance with (ii) or (ii) above during such Authorized Training Session in accordance with these license terms.

iv. Separation of Components. The components of the Licensed Content are licensed as a single unit. You may not separate the components and install them on different Devices.

v. Third Party Programs. The Licensed Content may contain third party programs. These license terms will apply to the use of those third party programs, unless other terms accompany those programs.

b. Trainers:

i. Trainers may Use the Licensed Content that you install or that is installed by an Authorized Learning Center on a classroom Device to deliver an Authorized Training Session.

ii. Trainers may also Use a copy of the Licensed Content as follows:

A. Licensed Device. The licensed Device is the Device on which you Use the Licensed Content. You may install and Use one copy of the Licensed Content on the licensed Device solely for your own personal training Use and for preparation of an Authorized Training Session.

Page 5: 2793A-ENU_TrainerWorkbook

B. Portable Device. You may install another copy on a portable device solely for your own personal training Use and for preparation of an Authorized Training Session.

4. ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS.

a. Authorized Learning Centers and Trainers:

i. Software.

Virtual Hard Disks. The Licensed Content may contain versions of Microsoft Windows XP, Windows Server 2003, and Windows 2000 Advanced Server and/or other Microsoft products which are provided in Virtual Hard Disks.

A. If the Virtual Hard Disks and the labs are launched through the Microsoft Learning Lab Launcher, then these terms apply:

TIME-SENSITIVE SOFTWARE. If the Software is not re-launched, it will stop running one hundred eighty days after you install it. You will not receive notice before it stops running. You may not be able to access data used or information stored with the Software when it stops running and/or when it is re-launched. You must remove the Software from the Devices at the end of each Authorized Training Session and reinstall and launch it prior to the beginning of the next Authorized Training Session.

B. If the Virtual Hard Disks require a product key to launch, then these terms apply:

Microsoft will deactivate the operating system associated with each Virtual Hard Disk. Before installing any Virtual Hard Disks on classroom Devices for use during an Authorized Training Session, you will obtain from Microsoft a product key for the operating system software for the Virtual Hard Disks and will activate such Software with Microsoft using such product key.

C. These terms apply to all Virtual Machines and Virtual Hard Disks:

You may only use the Virtual Machines and Virtual Hard Disks if you comply with the terms and conditions of this agreement and the following security requirements:

o You may not install Virtual Machines and Virtual Hard Disks on portable Devices or Devices that are accessible to other networks.

o You must remove Virtual Machines and Virtual Hard Disks from all classroom Devices at the end of each Authorized Training Session, except those held at Microsoft Certified Partners for Learning Solutions locations.

o You must remove the differencing drive portions of the Virtual Hard Disks from all classroom Devices at the end of each Authorized Training Session at Microsoft Certified Partners for Learning Solutions locations.

o You will ensure that the Virtual Machines and Virtual Hard Disks are not copied or downloaded from Devices on which you installed them.

o You will strictly comply with all Microsoft instructions relating to installation, use, activation and deactivation, and security of Virtual Machines and Virtual Hard Disks.

o You may not modify the Virtual Machines and Virtual Hard Disks or any contents thereof.

o You may not reproduce or redistribute the Virtual Machines or Virtual Hard Disks.

ii. Classroom Setup Guide. You will assure any Licensed Content installed for use during an Authorized Training Session will be done in accordance with the classroom set-up guide for the Course.

iii. Media Elements and Templates. You may allow Trainers and Students to use images, clip art, animations, sounds, music, shapes, video clips and templates provided with the Licensed Content

Page 6: 2793A-ENU_TrainerWorkbook

solely in an Authorized Training Session. If Trainers have their own copy of the Licensed Content, they may use Media Elements for their personal training use.

iv Evaluation Software. Any Software that is included in the Student Content designated as “Evaluation Software” may be used by Students solely for their personal training outside of the Authorized Training Session.

b. Trainers Only:

i. Use of PowerPoint Slide Deck Templates. The Trainer Content may include Microsoft PowerPoint slide decks. Trainers may use, copy and modify the PowerPoint slide decks only for providing an Authorized Training Session. If you elect to exercise the foregoing, you will agree or ensure Trainer agrees: (a) that modification of the slide decks will not constitute creation of obscene or scandalous works, as defined by federal law at the time the work is created; and (b) to comply with all other terms and conditions of this agreement.

ii. Use of Instructional Components in Trainer Content. For each Authorized Training Session, Trainers may customize and reproduce, in accordance with the MCT Agreement, those portions of the Licensed Content that are logically associated with instruction of the Authorized Training Session. If you elect to exercise the foregoing rights, you agree or ensure the Trainer agrees: (a) that any of these customizations or reproductions will only be used for providing an Authorized Training Session and (b) to comply with all other terms and conditions of this agreement.

iii. Academic Materials. If the Licensed Content contains Academic Materials, you may copy and use the Academic Materials. You may not make any modifications to the Academic Materials and you may not print any book (either electronic or print version) in its entirety. If you reproduce any Academic Materials, you agree that:

• The use of the Academic Materials will be only for your personal reference or training use

• You will not republish or post the Academic Materials on any network computer or broadcast in any media;

• You will include the Academic Material’s original copyright notice, or a copyright notice to Microsoft’s benefit in the format provided below:

Form of Notice:

© 2007 Reprinted for personal reference use only with permission by Microsoft Corporation. All rights reserved.

Microsoft, Windows, and Windows Server are either registered trademarks or trademarks of Microsoft Corporation in the US and/or other countries. Other product and company names mentioned herein may be the trademarks of their respective owners.

iv. Distributable Code. The Licensed Content may contain code that you are permitted to distribute in programs you develop if you comply with the terms below.

A. Right to use and Distribute. The code and text files listed below are “Distributable Code.”

• REDIST.TXT Files. You may copy and distribute the object code form of code listed in REDIST.TXT files.

• Sample Code. You may modify, copy, and distribute the source and object code form of code marked as “sample.”

• OTHER-DIST.TXT Files. You may copy and distribute the object code form of code listed in OTHER-DIST.TXT files.

• Third Party Distribution. You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs.

Page 7: 2793A-ENU_TrainerWorkbook

B. Distribution Requirements. For any Distributable Code you distribute, you must

• add significant primary functionality to it in your programs;

• require distributors and external end users to agree to terms that protect it at least as much as this agreement;

• display your valid copyright notice on your programs; and

• indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your programs.

C. Distribution Restrictions. You may not

• alter any copyright, trademark or patent notice in the Distributable Code;

• use Microsoft’s trademarks in your programs’ names or in a way that suggests your programs come from or are endorsed by Microsoft;

• distribute Distributable Code to run on a platform other than the Windows platform;

• include Distributable Code in malicious, deceptive or unlawful programs; or

• modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that

• the code be disclosed or distributed in source code form; or

• others have the right to modify it.

5. INTERNET-BASED SERVICES. Microsoft may provide Internet-based services with the Licensed Content. It may change or cancel them at any time. You may not use these services in any way that could harm them or impair anyone else’s use of them. You may not use the services to try to gain unauthorized access to any service, data, account or network by any means.

6. Scope of License. The Licensed Content is licensed, not sold. This agreement only gives you some rights to use the Licensed Content. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the Licensed Content only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the Licensed Content that only allow you to use it in certain ways. You may not

• install more copies of the Licensed Content on classroom Devices than the number of Students and the Trainer in the Authorized Training Session;

• allow more classroom Devices to access the server than the number of Students enrolled in and the Trainer delivering the Authorized Training Session if the Licensed Content is installed on a network server;

• copy or reproduce the Licensed Content to any server or location for further reproduction or distribution;

• disclose the results of any benchmark tests of the Licensed Content to any third party without Microsoft’s prior written approval;

• work around any technical limitations in the Licensed Content;

• reverse engineer, decompile or disassemble the Licensed Content, except and only to the extent that applicable law expressly permits, despite this limitation;

• make more copies of the Licensed Content than specified in this agreement or allowed by applicable law, despite this limitation;

• publish the Licensed Content for others to copy;

• transfer the Licensed Content, in whole or in part, to a third party;

Page 8: 2793A-ENU_TrainerWorkbook

• access or use any Licensed Content for which you (i) are not providing a Course and/or (ii) have not been authorized by Microsoft to access and use;

• rent, lease or lend the Licensed Content; or

• use the Licensed Content for commercial hosting services or general business purposes.

• Rights to access the server software that may be included with the Licensed Content, including the Virtual Hard Disks does not give you any right to implement Microsoft patents or other Microsoft intellectual property in software or devices that may access the server.

7. EXPORT RESTRICTIONS. The Licensed Content is subject to United States export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the Licensed Content. These laws include restrictions on destinations, end users and end use. For additional information, see www.microsoft.com/exporting.

8. NOT FOR RESALE SOFTWARE/LICENSED CONTENT. You may not sell software or Licensed Content marked as “NFR” or “Not for Resale.”

9. ACADEMIC EDITION. You must be a “Qualified Educational User” to use Licensed Content marked as “Academic Edition” or “AE.” If you do not know whether you are a Qualified Educational User, visit www.microsoft.com/education or contact the Microsoft affiliate serving your country.

10. TERMINATION. Without prejudice to any other rights, Microsoft may terminate this agreement if you fail to comply with the terms and conditions of these license terms. In the event your status as an Authorized Learning Center or Trainer a) expires, b) is voluntarily terminated by you, and/or c) is terminated by Microsoft, this agreement shall automatically terminate. Upon any termination of this agreement, you must destroy all copies of the Licensed Content and all of its component parts.

11. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the Licensed Content and support services.

12. APPLICABLE LAW.

a. United States. If you acquired the Licensed Content in the United States, Washington state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. The laws of the state where you live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort.

b. Outside the United States. If you acquired the Licensed Content in any other country, the laws of that country apply.

13. LEGAL EFFECT. This agreement describes certain legal rights. You may have other rights under the laws of your country. You may also have rights with respect to the party from whom you acquired the Licensed Content. This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so.

14. Disclaimer of Warranty. The Licensed Content is licensed “as-is.” You bear the risk of using it. Microsoft gives no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this agreement cannot change. To the extent permitted under your local laws, Microsoft excludes the implied warranties of merchantability, fitness for a particular purpose and non-infringement.

15. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.

This limitation applies to

• anything related to the Licensed Content, software, services, content (including code) on third party Internet sites, or third party programs; and

Page 9: 2793A-ENU_TrainerWorkbook

• claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law.

It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages.

Please note: As this Licensed Content is distributed in Quebec, Canada, some of the clauses in this agreement are provided below in French.

Remarque : Ce le contenu sous licence étant distribué au Québec, Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français.

EXONÉRATION DE GARANTIE. Le contenu sous licence visé par une licence est offert « tel quel ». Toute utilisation de ce contenu sous licence est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection dues consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues.

LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices.

Cette limitation concerne:

• tout ce qui est relié au le contenu sous licence , aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers ; et

• les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur.

Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre égard.

EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas.

Page 10: 2793A-ENU_TrainerWorkbook
Page 11: 2793A-ENU_TrainerWorkbook

Contents i

Table of Contents

Introduction Introduction ........................................................................................................................................ i Course Materials............................................................................................................................... ii Microsoft Learning Product Types................................................................................................... iv Microsoft Learning ........................................................................................................................... vi Microsoft Certification Program ...................................................................................................... vii Facilities........................................................................................................................................... xi About This Course.......................................................................................................................... xii Prerequisites.................................................................................................................................. xiv Course Outline................................................................................................................................ xv Virtual Machine Environment........................................................................................................ xvii Demonstration: Using Microsoft Virtual PC ................................................................................... xix Introduction to Adventure Works ................................................................................................... xxi

Module 1: Introduction to SQL Server Reporting Services Module Overview.......................................................................................................................... 1-1 Lesson 1: Overview of SQL Server Reporting Services............................................................... 1-2 Lesson 2: Installing Reporting Services ....................................................................................... 1-8 Lesson 3: Reporting Services Tools........................................................................................... 1-14 Lab: Using Reporting Services Tools ......................................................................................... 1-17

Module 2: Authoring Basic Reports Module Overview.......................................................................................................................... 2-1 Lesson 1: Creating a Basic Table Report..................................................................................... 2-2 Lesson 2: Formatting Report Pages........................................................................................... 2-11 Lesson 3: Calculating Values ..................................................................................................... 2-17 Lab: Creating a Simple Report ................................................................................................... 2-25

Module 3: Enhancing Basic Reports Module Overview.......................................................................................................................... 3-1 Lesson 1: Interactive Navigation .................................................................................................. 3-2 Lesson 2: Displaying Data............................................................................................................ 3-7 Lab: Enhancing a Report............................................................................................................ 3-17

Module 4: Manipulating Data Sets Module Overview.......................................................................................................................... 4-1 Lesson 1: Defining Report Data ................................................................................................... 4-2 Lesson 2: Using Parameters and Filters ...................................................................................... 4-6 Lesson 3: Using Parameter Lists................................................................................................ 4-14 Lab: Manipulating Data Sets ...................................................................................................... 4-20

Page 12: 2793A-ENU_TrainerWorkbook

ii Contents

Module 5: Using Report Models Module Overview.......................................................................................................................... 5-1 Lesson 1: Creating Report Models............................................................................................... 5-2 Lesson 2: Using Report Builder.................................................................................................... 5-9 Lab: Working with Report Models............................................................................................... 5-18

Module 6: Publishing and Executing Reports Module Overview.......................................................................................................................... 6-1 Lesson 1: Publishing Reports....................................................................................................... 6-2 Lesson 2: Executing Reports...................................................................................................... 6-10 Lesson 3: Creating Cached Instances ....................................................................................... 6-17 Lesson 4: Creating Snapshots and Report History .................................................................... 6-23 Lab: Publishing and Executing Reports ..................................................................................... 6-33

Module 7: Using Subscriptions to Distribute Reports Module Overview.......................................................................................................................... 7-1 Lesson 1: Introduction to Report Subscriptions............................................................................ 7-2 Lesson 2: Creating Report Subscriptions..................................................................................... 7-5 Lesson 3: Managing Report Subscriptions................................................................................. 7-11 Lab: Implementing Subscriptions ............................................................................................... 7-17

Module 8: Administering Reporting Services Module Overview.......................................................................................................................... 8-1 Lesson 1: Server Administration................................................................................................... 8-2 Lesson 2: Performance and Reliability Monitoring ....................................................................... 8-9 Lesson 3: Administering Report Server Databases ................................................................... 8-19 Lesson 4: Security Administration .............................................................................................. 8-23 Lab: Administering Reporting Services ...................................................................................... 8-35

Module 9: Programming Reporting Services Module Overview.......................................................................................................................... 9-1 Lesson 1: Querying for Server Information Using a Web Service................................................ 9-2 Lesson 2: Automating Report Management................................................................................. 9-7 Lesson 3: Rendering Reports..................................................................................................... 9-13 Lesson 4: Creating Custom Code .............................................................................................. 9-20 Lab: Programming Reporting Services ...................................................................................... 9-24 Course Evaluation ...................................................................................................................... 9-31 Lab Answer Key

Page 13: 2793A-ENU_TrainerWorkbook

Module 0: Introduction

Table of Contents Introduction i Course Materials ii Microsoft Learning Product Types iv Microsoft Learning vi Microsoft Certification Program vii Facilities xi About This Course xii Prerequisites xiv Course Outline xv Virtual Machine Environment xvii Demonstration: Using Microsoft Virtual PC xix Introduction to Adventure Works xxi

Page 14: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 15: 2793A-ENU_TrainerWorkbook

Module 0: Introduction i

Introduction

Page 16: 2793A-ENU_TrainerWorkbook

ii Module 0: Introduction

Course Materials

The following materials are included with your kit:

• Student workbook. The student workbook contains the material covered in class. • Student Materials CD. The Student Materials CD contains a Web page that provides

you with links to resources pertaining to this course, including additional readings, discussion answer keys, multimedia presentations, and course-related Web sites.

Note To open the Web page, insert the Student Materials CD into the CD-ROM drive, and then in the root directory of the CD, double-click StartCD.exe.

• Course evaluation. At the end of the course, you will have the opportunity to complete an online evaluation to provide feedback on the course, training facility, and instructor.

To provide additional comments or feedback on the course, send e-mail to [email protected]. To inquire about the Microsoft Certification Program, send e-mail to [email protected].

Page 17: 2793A-ENU_TrainerWorkbook

Module 0: Introduction iii

Document Conventions The following conventions are used in course materials to distinguish elements of the text.

Convention Use

Bold Represents commands, command options, and syntax that must be typed exactly as shown. It also indicates commands on menus and buttons, dialog box titles and options, and icon and menu names.

Italic In syntax statements or descriptive text, indicates argument names or placeholders for variable information. Italic is also used for introducing new terms, for book titles, and for emphasis in the text.

Title Capitals Indicate domain names, user names, computer names, directory names, and folder and file names, except when specifically referring to case-sensitive names. Unless otherwise indicated, you can use lowercase letters when you type a directory name or file name in a dialog box or at a command prompt.

ALL CAPITALS Indicate the names of keys, key sequences, and key combinations —for example, ALT+SPACEBAR.

monospace Represents code samples or examples of screen text.

[ ] In syntax statements, enclose optional items. For example, [filename] in command syntax indicates that you can choose to type a file name with the command. Type only the information within the brackets, not the brackets themselves.

{ } In syntax statements, enclose required items. Type only the information within the braces, not the braces themselves.

| In syntax statements, separates an either/or choice.

► Indicates a procedure with sequential steps.

... In syntax statements, specifies that the preceding item may be repeated.

.

.

Represents an omitted portion of a code sample.

Page 18: 2793A-ENU_TrainerWorkbook

iv Module 0: Introduction

Microsoft Learning Product Types

Microsoft Learning offers the following instructor-led products. Each is specific to a particular audience type and level of experience. The different product types also tend to suit different learning styles. These types are as follows:

• Courses are for information technology (IT) professionals and developers who are new to a particular product or technology and for experienced individuals who prefer to learn in a traditional classroom format. Courses provide a relevant and guided learning experience that combines lecture and practice to deliver thorough coverage of a Microsoft product or technology. Courses are designed to address the needs of learners engaged in planning, design, implementation, management, and support phases of the technology adoption life-cycle. They provide detailed information by focusing on concepts and principles, reference content, and in-depth hands-on lab activities to ensure knowledge transfer. Typically, the content of a course is broad, addressing a wide range of tasks necessary for the job role.

• Workshops are for knowledgeable IT professionals and developers who learn best by doing and exploring. Workshops provide a hands-on learning experience in which participants use Microsoft products in a safe and collaborative environment based on real-world scenarios.

• iWorker courses or Information Worker Courses are scenario-based courseware lines to compete in the desktop applications market. This scenario-based courseware line will fill a need for applications training that supports on-the-job performance improvement with business and productivity solutions (rather than feature-based training). The purpose of an iWorker course is to promote skills/ knowledge transfer in the context of business scenarios to accomplish business objectives by working individually or collaboratively to find answers. iWorker courses are aimed at users

Page 19: 2793A-ENU_TrainerWorkbook

Module 0: Introduction v

who have working knowledge of the technology and are interested in applying that knowledge in specific business scenarios.

• Clinics are for IT professionals, developers and technical decision makers. Clinics offer a detailed “how to” presentation that describes the features and functionality of an existing or new Microsoft product or technology, and that showcases product demonstrations and solutions. Clinics focus on how specific features will solve business problems.

• First-look Clinics are products specifically designed to deliver early content or critical information that Product Groups or other internal customers need communicated quickly and broadly. The First Look products convey knowledge-based (not skills-based) information to an audience profile identified as high-level Business Decision Makers.

• Hands-on Labs provide IT professionals and developers with hands-on experience with an existing or new Microsoft product or technology. Hands-on labs provide a realistic and safe environment to encourage knowledge transfer by learning through doing. The labs provided are completely prescriptive so that no lab answer keys are required. There is very little lecture or text content provided in hands-on labs, aside from lab introductions, context setting, and lab reviews.

Page 20: 2793A-ENU_TrainerWorkbook

vi Module 0: Introduction

Microsoft Learning

Microsoft Learning develops Official Microsoft Learning Product (OMLP) courseware for computer professionals who design, develop, support, implement, or manage solutions by using Microsoft products and technologies. These learning products provide comprehensive, skills-based training in instructor-led and online formats.

Additional Recommended Learning Products Each learning product relates in some way to other learning products. A related product may be a prerequisite, a follow-up course, clinic, or course in a recommended series, or a learning product that offers additional training.

Other related learning products may become available in the future, so for up-to-date information about recommended learning products, visit the Microsoft Learning Web site.

Microsoft Learning Information For more information, visit the Microsoft Learning Web site at http://www.microsoft.com/learning/.

Page 21: 2793A-ENU_TrainerWorkbook

Module 0: Introduction vii

Microsoft Certification Program

Microsoft Learning offers a variety of certification credentials for developers and IT professionals. The Microsoft Certification Program (MCP) is the leading certification program for validating your experience and skills, keeping you competitive in today’s changing business environment.

Related Certification Exams This course helps students to prepare for Exam 70-445: TS: Microsoft SQL Server 2005 Business Intelligence - Implementation and Maintenance.

Exam 70-445 is core exam for the MCTS: SQL Server 2005 Business Intelligence certification.

MCP Certifications The MCP program includes the following certifications.

MCITP

The new Microsoft Certified IT Professional (MCITP) credential allows IT professionals to distinguish themselves as experts in their specific area of focus. There is a straightforward upgrade path from the MCDBA certification to the new MCITP credentials. There are currently three IT Professional certifications—in database development, database administration, and business intelligence:

• Microsoft Certified IT Professional: Database Developer • Microsoft Certified IT Professional: Database Administrator • Microsoft Certified IT Professional: Business Intelligence Developer

Page 22: 2793A-ENU_TrainerWorkbook

viii Module 0: Introduction

MCPD

The Microsoft Certified Professional Developer (MCPD) credential highlights developer job roles, featuring specific areas of expertise. There is a straightforward upgrade path from the MCAD and MCSD for Microsoft .NET certifications to the new MCPD credentials. There are three MCPD certification paths—in Web application development, Windows development, and enterprise applications development:

• Microsoft Certified Professional Developer: Web Developer • Microsoft Certified Professional Developer: Windows Developer • Microsoft Certified Professional Developer: Enterprise Applications Developer

MCTS

The Microsoft Certified Technology Specialist (MCTS) credential enables professionals to target specific technologies and distinguish themselves by demonstrating in-depth knowledge of and expertise in the technologies with which they work. There are currently five MCTS certifications:

• Microsoft Certified Technology Specialist: .NET Framework 2.0 Web Applications • Microsoft Certified Technology Specialist: .NET Framework 2.0 Windows

Applications • Microsoft Certified Technology Specialist: .NET Framework 2.0 Distributed

Applications • Microsoft Certified Technology Specialist: SQL Server™ 2005 • Microsoft Certified Technology Specialist: BizTalk® Server

MCDST on Microsoft Windows®

The Microsoft Certified Desktop Support Technician (MCDST) certification is designed for professionals who successfully support and educate end users and troubleshoot operating system and application issues on desktop computers running the Windows operating system.

MCSA on Microsoft Windows Server™ 2003

The Microsoft Certified Systems Administrator (MCSA) certification is designed for professionals who implement, manage, and troubleshoot existing network and system environments based on the Windows Server 2003 platform. Implementation responsibilities include installing and configuring parts of systems. Management responsibilities include administering and supporting systems.

MCSE on Microsoft Windows Server 2003

The Microsoft Certified Systems Engineer (MCSE) credential is the premier certification for professionals who analyze business requirements and design and implement

Page 23: 2793A-ENU_TrainerWorkbook

Module 0: Introduction ix

infrastructure for business solutions based on the Windows Server 2003 platform. Implementation responsibilities include installing, configuring, and troubleshooting network systems.

MCAD for Microsoft .NET

The Microsoft Certified Application Developer (MCAD) for Microsoft .NET credential provides industry recognition for professional developers who use Microsoft Visual Studio® .NET and Web services to develop and maintain department-level applications, components, Web or desktop clients, or back-end data services, or who work in teams developing enterprise applications. The credential covers job tasks ranging from developing to deploying and maintaining these solutions.

MCSD for Microsoft .NET

The Microsoft Certified Solution Developer (MCSD) for Microsoft .NET credential is the top-level certification for advanced developers who design and develop leading-edge enterprise solutions by using Microsoft development tools and technologies as well as the Microsoft .NET Framework. The credential covers job tasks ranging from analyzing business requirements to maintaining solutions.

MCDBA on Microsoft SQL Server 2000

The Microsoft Certified Database Administrator (MCDBA) credential is the premier certification for professionals who implement and administer SQL Server 2000 databases. The certification is appropriate for individuals who derive physical database designs, develop logical data models, create physical databases, create data services by using Transact-SQL, manage and maintain databases, configure and manage security, monitor and optimize databases, and install and configure SQL Server.

MCP

The Microsoft Certified Professional (MCP) credential is for individuals who have the skills to successfully implement a Microsoft product or technology as part of a business solution in an organization. Hands-on experience with the product is necessary to successfully achieve certification.

MCT

Microsoft Certified Trainers (MCTs) demonstrate the instructional and technical skills that qualify them to deliver Official Microsoft Learning Products through a Microsoft Certified Partner for Learning Solutions (CPLS).

Certification Requirements

Certification requirements differ for each certification category and are specific to the products and job functions addressed by the certification. To earn a certification credential, you must pass rigorous certification exams that provide a valid and reliable measure of technical proficiency and expertise.

Page 24: 2793A-ENU_TrainerWorkbook

x Module 0: Introduction

Additional Information: See the Microsoft Learning Web site at http://www.microsoft.com/learning/. You can also send e-mail to [email protected] if you have specific certification questions.

Acquiring the Skills Tested by an MCP Exam Official Microsoft Learning Products can help you develop the skills that you need to do your job. They also complement the experience that you gain while working with Microsoft products and technologies. However, no one-to-one correlation exists between Official Microsoft Learning Products and MCP exams. Microsoft does not expect or intend for the courses to be the sole preparation method for passing MCP exams. Practical product knowledge and experience are also necessary to pass MCP exams.

To help prepare for MCP exams, use the preparation guides that are available for each exam. Each Exam Preparation Guide contains exam-specific information, such as a list of the topics on which you will be tested. These guides are available on the Microsoft Learning Web site at http://www.microsoft.com/learning/.

Page 25: 2793A-ENU_TrainerWorkbook

Module 0: Introduction xi

Facilities

Page 26: 2793A-ENU_TrainerWorkbook

xii Module 0: Introduction

About This Course

This section provides you with a brief description of the course, objectives, and target audience.

Description This course teaches you how to implement a Reporting Services solution in your organization. The course discusses how to use the Reporting Services development tools to create reports, and how to use the Reporting Services management and administrative tools to manage a Reporting Services solution.

Audience The audience for of this course is information technology (IT) professionals and developers who need to implement reporting solutions by using Microsoft SQL Server 2005 Reporting Services.

Course Objectives After completing this course, you will be able to:

• Describe SQL Server Reporting Services and its components. • Create a Reporting Services report. • Enhance a Reporting Services report. • Create and manipulate data sets. • Use report models to implement reporting for business users. • Configure report publishing and execution settings. • Implement subscriptions for reports. • Administer Reporting Services.

Page 27: 2793A-ENU_TrainerWorkbook

Module 0: Introduction xiii

• Implement custom Reporting Services applications.

Page 28: 2793A-ENU_TrainerWorkbook

xiv Module 0: Introduction

Prerequisites

This course requires that you meet the following prerequisites:

• Exposure to creating reports in Microsoft Access or other third-party reporting products, such as Crystal Reports

• Conceptual understanding of the push and pull distribution/subscription paradigm • Experience navigating the Microsoft Windows Server™ environment • Experience with Windows services (starting and stopping) • Experience creating service accounts and permissions • Experience with Microsoft SQL Server, including:

• SQL Server Agent

• SQL Server query language (SELECT, UPDATE, INSERT, and DELETE)

• SQL Server System tables

• SQL Server accounts (users and permissions)

Page 29: 2793A-ENU_TrainerWorkbook

Module 0: Introduction xv

Course Outline

Module 1, “Introduction to Microsoft SQL Server Reporting Services,” introduces the role that Reporting Services plays in an organization’s reporting life cycle, the key features offered by Reporting Services, and the components that make up the Reporting Services architecture. After you complete this module, you will be able to describe the scenarios in which you can use Reporting Services.

Module 2, “Authoring Basic Reports,” introduces the fundamentals of report authoring, including configuring data sources and data sets, creating tabular reports, summarizing data, and applying basic formatting. After you complete this module, you will be able to create a basic report.

Module 3, “Enhancing Basic Reports,” introduces navigational controls and some additional types of data regions, and discusses how to use them to enhance a basic report. After you complete this module, you will be able to create interactive navigation by using report links and display data by using data regions.

Module 4, “Manipulating Data Sets,” explores data sets to a greater depth, including the use of alternative data sources and interacting with a data set through the use of parameters. You will learn how to dynamically modify the data set underlying a data region by allowing parameters to be sent to the underlying query, as well as learn to use best practices to implement static and dynamic parameter lists when interacting with queries and stored procedures. After you complete this module, you will be able to describe the features of a data set.

Module 5, “Using Report Models,” describes how to create a report model so that business users can create their own reports without using the full Report Designer

Page 30: 2793A-ENU_TrainerWorkbook

xvi Module 0: Introduction

development environment. You will also learn how to use Report Builder to create a report from a report model.

Module 6, “Publishing and Executing Reports,” explains the various options you can use to publish reports to the report server and execute them. After you complete this module, you will be able to publish content to the report server.

Module 7, “Using Subscriptions to Distribute Reports,” describes how to implement subscriptions so that you can distribute reports either automatically by e-mail or by publishing reports to a shared folder.

Module 8, “Administering Reporting Services,” discusses how to administer the Reporting Services server, how to monitor and optimize the performance of the report server, how to maintain the Reporting Services databases, and how to keep the system secure. After you complete this module, you will be able to administer a report server.

Module 9, “Programming Reporting Services,” explains how to query Reporting Services information programmatically and how to automate report management tasks. You will also learn how to render reports without relying on Report Manager. Finally, you will learn how you can extend the feature set of your report server by creating custom code. After you complete this module, you will be able to retrieve information about the report server programmatically.

Page 31: 2793A-ENU_TrainerWorkbook

Module 0: Introduction xvii

Virtual Machine Environment

This section provides the information for setting up the classroom environment to support the business scenario of the course.

Virtual Machine Configuration In this course, you will use Microsoft Virtual PC 2004 to perform the labs.

Important: At the end of each lab, you must close the virtual machine and must not save any changes. To close a virtual machine without saving the changes, perform the following steps: 1. On the virtual machine, on the Action menu, click Close. 2. In the Close dialog box, in the What do you want the virtual machine to do? list, click Turn off and delete changes, and then click OK.

The following table shows the role of each virtual machine used in this course.

Virtual machine Role

2793A-MIA-SQL-nn Report server and development computer

(nn denotes the module number)

Software Configuration The following software is installed on each VM:

• Microsoft Windows Server 2003 SP1 • Microsoft SQL Server 2005 SP1 • Microsoft Visual Studio® Team System

Page 32: 2793A-ENU_TrainerWorkbook

xviii Module 0: Introduction

Classroom Setup Each classroom computer will have the same virtual machine configured in the same way.

Course Hardware Level To ensure a satisfactory student experience, Microsoft Learning requires a minimum equipment configuration for trainer and student computers in all Microsoft Certified Partner for Learning Solutions (CPLS) classrooms in which Official Microsoft Learning Product courseware are taught.

This course requires that you have a computer that meets or exceeds hardware level 5, which specifies a 2.4–gigahertz (GHz) (minimum) Pentium 4 or equivalent CPU, at least 2 gigabytes (GB) of RAM, 16 megabytes (MB) of video RAM, and a 7200 RPM 40-GB hard disk.

Page 33: 2793A-ENU_TrainerWorkbook

Module 0: Introduction xix

Demonstration: Using Microsoft Virtual PC

In this demonstration, your instructor will help familiarize you with the Virtual PC environment in which you will work to complete the labs in this course. You will learn:

• How to open Virtual PC. • How to start Virtual PC. • How to log on to Virtual PC. • How to switch between full screen and window modes. • How to tell the difference between the virtual machines that are used in the practices

for this course. • That the virtual machines can communicate with each other and with the host, but

they cannot communicate with other computers that are outside of the virtual environment. (For example, no Internet access is available from the virtual environment.)

• How to close Virtual PC.

Keyboard Shortcuts While working in the Virtual PC environment, you may find it helpful to use keyboard shortcuts. All Virtual PC shortcuts include a key that is referred to as the HOST key or the RIGHT-ALT key. By default, the HOST key is the ALT key on the right side of your keyboard. Some useful shortcuts include:

• RIGHT-ALT+DELETE to log on to the Virtual PC. • RIGHT-ALT+ENTER to switch between full screen mode and window modes. • RIGHT-ALT+RIGHT ARROW to display the next Virtual PC.

Page 34: 2793A-ENU_TrainerWorkbook

xx Module 0: Introduction

For more information about Virtual PC, see Virtual PC Help.

Page 35: 2793A-ENU_TrainerWorkbook

Module 0: Introduction xxi

Introduction to Adventure Works

In the labs throughout this course, you will be working as a Reporting Services technology specialist for Adventure Works.

Adventure Works is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European, and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base. Branch sales offices are located in Barcelona, Hong Kong, Cape Town, Beirut, and Sao Paulo. Manufacturing is located in wholly owned subsidiaries in Mexico and Indonesia.

Page 36: 2793A-ENU_TrainerWorkbook
Page 37: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services

Table of Contents Module Overview 1-1

Lesson 1: Overview of SQL Server Reporting Services 1-2

Lesson 2: Installing Reporting Services 1-8 Lesson 3: Reporting Services Tools 1-14 Lab: Using Reporting Services Tools 1-17

Page 38: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 39: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-1

Module Overview

Objectives After completing this module, you will be able to:

• Describe the features of SQL Server Reporting Services. • Install Reporting Services. • Describe the Reporting Services tools.

Page 40: 2793A-ENU_TrainerWorkbook

1-2 Module 1: Introduction to SQL Server Reporting Services

Lesson 1: Overview of SQL Server Reporting Services

Objectives After completing this lesson, you will be able to:

• Describe the reporting lifecycle. • Describe the highlights of Reporting Services. • Describe possible uses of Reporting Services.

Page 41: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-3

The Reporting Lifecycle

The process of report creation, administration, and dissemination (known collectively as the reporting lifecycle) can be broken down into three stages: authoring, management, and delivery.

Key Points • In the authoring stage, the report author defines the report data and presentation.

• Report Definition Language (RDL) provides an Extensible Markup Language (XML) representation of the report definition.

• ADO.NET-managed data providers allow access to OLE DB, open database connectivity (ODBC), and XMLA (XML for Analysis) data sources.

• Reports can be authored by using provided tools such as Report Designer or Report Builder, or custom tools built by third parties.

• In the management stage, the author publishes the report to a central location where the report manager can administer the report security and execution schedule. • Reporting Services uses the central Report Server database for report storage,

public consumption, and report sharing.

• After publishing reports to the Report Server database, you can create an execution schedule and set security options for the report.

• Report Manager is the supplied Web-based content management tool for administering reports. You can also use a custom or third-party management tool.

• In the delivery stage, you can make reports available in a number of rendered formats. Reports can also be delivered on demand or scheduled based on an event.

Page 42: 2793A-ENU_TrainerWorkbook

1-4 Module 1: Introduction to SQL Server Reporting Services

• At run time, Reporting Services processes or renders the presentation style of the report. Because presentation processing occurs after data retrieval, multiple users can review the same report simultaneously in formats designed for different devices, or quickly change the viewing format of the report.

• Reporting Services provides flexible report delivery mechanisms to support both push and pull reporting scenarios. Pull scenarios typically involve browser-based access to a folder structure, which provides a familiar metaphor for finding and working with content. Report Manager is the supplied Web-based browser interface for viewing reports. You can also use a custom portal or report access interface to access reports.

• In a push scenario, e-mail delivery automates report processing and routes rendered reports to users’ inboxes. You can also extend Reporting Services to create your own report delivery mechanisms.

Page 43: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-5

Highlights of Reporting Services

As a component of SQL Server 2005, Reporting Services provides a number of key features. In this topic, you will explore some of those features in the context of the reporting lifecycle.

Key Points • In the authoring stage of the reporting lifecycle, Reporting Services supports the

following important features and functionality: • Access to a wide range of supported data sources using ADO.NET managed

providers.

• You can create RDL files using Report Designer, Report Builder, or any XML compatible editor.

• Data regions provide a wide range of formatting options during report design. Supported data regions include Matrix, Table, List, and Chart. You can gain further flexibility through the use of drill-through, through which users can navigate to hidden detail information, and the linking of reports.

• In the management stage of the reporting lifecycle, Reporting Services supports following important features and functionality: • With parameterized reports, users can specify values such as month or

salesperson to generate specific reports, or they can use default values provided by the report.

• The execution properties of a report can be configured to provide live data (on-demand execution), multiuser shared cache (data is cached for limited periods), or snapshots (retained static data for repeated viewing).

Page 44: 2793A-ENU_TrainerWorkbook

1-6 Module 1: Introduction to SQL Server Reporting Services

• SQL Server Agent provides report scheduling. The Report History feature maintains an archive of copies of processed reports so that you can view data at a particular point in time.

• Role-based security allows you to tailor security to individual users. Administrators can delegate content management functions for different reports to specific individuals.

• In the delivery stage of the reporting life cycle, Reporting Services supports the following important features and functionality: • You can render reports in the following formats:

• Web formats (HTML)

• Print formats (PDF, TIFF)

• Data Formats (Microsoft Excel®, XML, CSV)

• Reporting Services provides an open application programming interface (API) to extend the rendering options.

• Reporting Services supports scheduled or event-driven delivery mechanisms. With the Subscription feature, individual users can subscribe to receive a particular report when certain conditions arise, such as when the report data has been updated (data-driven). Reports can be delivered as rendered reports or as URLs.

Page 45: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-7

Reporting Services Scenarios

Reporting Services can support multiple scenarios that include an organization’s internal and external business reporting needs.

Key Points • Internal reporting typically supports the reporting needs of departments within your

organization. Examples of internal reporting scenarios include order detail reports for the Customer Support department, financial statements for the Finance department, and salesperson performance for the Sales department. Other reports can cross department boundaries to provide corporate reports that take a higher view of the data.

• External reporting supports the business-to-business exchange of information by allowing users to access reports through extranet connections. Customer invoices and shareholder reports are both examples of external reporting scenarios.

• Embedded reporting provides report integration for portals and applications such as company portals and line-of-business applications, including customer relations management (CRM) or manufacturing control systems.

Page 46: 2793A-ENU_TrainerWorkbook

1-8 Module 1: Introduction to SQL Server Reporting Services

Lesson 2: Installing Reporting Services

Objectives After completing this lesson, you will be able to:

• Describe the Reporting Services architecture. • Install Reporting Services. • Describe the possible installation scenarios.

Page 47: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-9

Reporting Services Architecture

Reporting Services is a .NET-based platform that includes a comprehensive set of tools that you can use to integrate a reporting solution into any centrally-managed technical environment.

Key Points • Report Server contains a Web service that includes several subcomponents to manage

report processing: data processing, report rendering, security policies, and report delivery. The Report Manager Web site provides a graphical interface to the Web service.

• The Report Server database is a SQL Server database that stores the information that Report Server uses to manage reports and resources. The Report Server database performs stateless storage of all information. This means that Report Server treats each interaction request solely on information in that request. You can have one or more Report Servers that all point to the same Report Server database.

• Programmatic interfaces allow you to create custom client applications that utilize Reporting Services, or alternatively you can enhance the reports system by adding new features. • Because Report Server is implemented as a Web service that uses published APIs,

it can be accessed by using tools that are included with Reporting Services or through a custom interface. Through a Simple Object Access Protocol (SOAP) API over HTTP, you can create custom tools for any stage of the reporting lifecycle—authoring, management, or delivery.

• Managed code is code that runs on the Microsoft .NET Framework’s common language runtime. A managed code API is available so that you can easily

Page 48: 2793A-ENU_TrainerWorkbook

1-10 Module 1: Introduction to SQL Server Reporting Services

develop, install, and manage extensions that are consumed by many Reporting Services components. Assemblies are collections of code that are built, versioned, and deployed as a single implementation unit. You can create assemblies by using the.NET Framework and add new Reporting Services functionality for rendering, security, delivery, and data-processing to meet your evolving business needs.

Page 49: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-11

Reporting Services Installation

Installing Reporting Services will involve modifications to a server computer and potentially client computers, depending on the client requirements.

Key Points • Reporting Services is installed as part of the SQL Server 2005 setup when selected as

a requested component. You can either install Reporting Services on the local machine using a default installation or create a “files-only” installation that requires the Reporting Services Configuration Tool to complete the installation.

• You can install multiple instances of Reporting Services on the same computer. This is useful if you want to host different content for specific sites, each with its own report server database, configuration files, and virtual directories.

• To install a Report Server, your server needs the following features: • Microsoft Internet Information Services (IIS) version 5 or later installed

• .NET Framework 2.0 installed

• Access to an SMTP Server for e-mail delivery of reports (optional)

• Reporting Services can store report data in either SQL Server 2005 or SQL Server 2005 Express.

• Client computers need the following features: • A Web browser for viewing reports and interacting with Report Manager.

Microsoft Internet Explorer® 5.5 and later supports all reporting features, but other browsers may not support features such as document map, searching within the report, zoom, and fixed table headers.

Page 50: 2793A-ENU_TrainerWorkbook

1-12 Module 1: Introduction to SQL Server Reporting Services

• .NET Framework 2.0 to support Business Intelligence Development Studio (BIDS) or Report Builder for designing reports (optional).

Page 51: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-13

Installation Scenarios

When you install Reporting Services, you can consider three different installation scenarios to best suit your environment.

Key Points • A single server installation places the Report Server, Report Manager, and Report

Server databases on the same physical server. This approach is suitable for small businesses that may have limited hardware resources, but it does not provide failover support or the ability to cope with increased user demands.

• A remote database server installation places the Report Server and Report Manager on a Web server with the Report Server databases on their own remote server. This provides better performance than a single server installation, because both servers can process their own features without compromising the other server. In a scenario that includes an Internet connection, it also allows the report database to be kept secure away from the Internet-facing Web server.

• A Web farm installation provides greater scalability and failover support than a remote database installation. Multiple Web servers can handle the requests for reports, while a SQL Server failover cluster can provide fault tolerance of the reporting databases to keep the system running when a computer goes down.

Page 52: 2793A-ENU_TrainerWorkbook

1-14 Module 1: Introduction to SQL Server Reporting Services

Lesson 3: Reporting Services Tools

Objectives After completing this lesson, you will be able to:

• Describe the Reporting Services developer tools. • Describe the Reporting Services management tools.

Page 53: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-15

Reporting Services Developer Tools

Reporting Services provides various tools that you can use to develop, test, and upload reports by various members within an organization.

Key Points • With Report Designer, you can develop reports interactively within the Microsoft

Visual Studio environment (or BIDS) and then publish them to a Report Server when they are ready to be deployed. If you do not have Visual Studio 2005 installed, SQL Server Setup installs the shell so that you can run Report Designer.

• With Model Designer, you can create a report model that Report Builder users can use to help them build ad hoc reports. A report model is a business description of the underlying database that describes the data in terms of entities, attributes, and relationships (roles).

• With Report Builder, information workers can build reports without having to understand the underlying data source structures in the database. This tool is deployed using the .NET Framework 2.0 ClickOnce deployment feature, and uses report models created with Model Designer.

Page 54: 2793A-ENU_TrainerWorkbook

1-16 Module 1: Introduction to SQL Server Reporting Services

Reporting Services Management Tools

Reporting Services provides various tools to manage and configure the Report Server environment.

Key Points • Report Manager is a Web-based report access and management tool that you connect

to through a Web browser. The tool consists of an ASP.NET Web site that uses the Report Server Web services to provide users with the ability to browse existing reports, upload new reports, and manage all aspects of a report, including execution properties, security, and subscriptions.

• The Reporting Services Configuration Tool provides a graphical interface that uses the Reporting Services Windows Management Instrumentation (WMI) to configure a report server.

• You can use three command prompt utilities to manually configure parts of a report server. • Rsconfig.exe manages a report server connection to the report server database.

• Rskeymgmt.exe manages encryption keys used by the report server so that items such as connection strings are maintained securely.

• Rs.exe runs Microsoft Visual Basic® .NET scripts that perform automated management features like copying data between report server databases, publishing reports, or creating items in a report server database.

Page 55: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-17

Lab: Using Reporting Services Tools

After completing this lab, you will be able to:

• View and modify reports using Report Manager. • Preview and modify reports using Report Designer.

Estimated time to complete this lab: 30 minutes

Lab Setup For this lab, you will use the available virtual machine environment. Before you begin the lab, you must:

• Start the 2793A-MIA-SQL-01 virtual machine. • Log on to MIAMI by using the user name Student and the password Pa$$w0rd.

Lab Scenario In this lab, you will familiarize yourself with a sample of the AdventureWorks reports using both the Report Designer, and the Report Manager.

Page 56: 2793A-ENU_TrainerWorkbook

1-18 Module 1: Introduction to SQL Server Reporting Services

Exercise 1: Exploring Report Designer In this exercise, you will use Report Designer to examine and edit the Sales Order Detail report.

Tasks Supporting information

1. Open the AdventureWorks solution.

• Using Business Intelligence Development Studio, open the AdventureWorks Sample Reports solution located in the D:\Labfiles\Starter folder.

2 Explore the Sales Order Detail report.

• Open and preview the Sales Order Detail report. Notice that the report is a parameterized report showing the detail of a particular sales order.

• In Layout view, notice that the report is made up of a few distinct areas: • A header consisting of an Adventure Works image on the left,

and a Sales Order title on the right together with the report parameter.

• A rectangle containing the billing, shipping and order header details.

• A table region containing the order detail together with a footer containing totals.

3. Alter the Sales Order Detail report.

• Add a Textbox control to the report, just above the text box containing the Sales Order title, aligned to the left edge.

• Format the new text box to be right-aligned and bold. • Set the Value property to:

=Fields!OrderDate.Value • Set the Format property to d.

4. Alter the OrderDetail table region.

• Set the Value property of the cell in the footer row of the Subtotal column of the OrderDetail table to: =sum(Fields!LineTotal.Value)

• Set the Format property for this cell to c. • Right-align and bold the text box. • Preview the report to view your changes.

5. Change report parameter available values.

• To edit report parameters, while viewing the Layout tab, on the Report menu click Report Parameters.

• Under Available values, type the following values in both the labels and values: • SO50750 • SO50751 • SO50752

• Preview the report for the sales order number SO50751.

Page 57: 2793A-ENU_TrainerWorkbook

Module 1: Introduction to SQL Server Reporting Services 1-19

Exercise 2: Exploring Report Manager In this exercise, you will use the Report Manager to view the Product Catalog report. You will then edit the properties of the Sales Order report.

Tasks Supporting information

1. Start Report Manager. • Use Internet Explorer to open Report Manager at http://miami/reports.

2. Examine the Product Catalog report.

• The Product Catalog report is in the AdventureWorks Sample Reports folder, which is in the Samples folder.

• Note that there is a document map on the left of the report together with a number of catalog pictures on the right.

• Use the document map to view the product details for the Mountain-100 mountain bike.

• Notice that you can navigate through the report by using: • The Next Page button. • The Current Page box. • The Find Text box.

3. View the Company Sales report.

• In the AdventureWorks Sample Reports folder, open the Company Sales report.

• Notice that you can expand the product categories and the years to drill-down and find more detailed information.

4. Export the Company Sales report to Excel.

• Using the Export list, export the report to Excel. • View the report in Microsoft Office Excel.

5. Examine Sales Order report properties.

• Using the Properties tab, view the General properties of the report. Note that it is possible to rename the report, and to add a description.

• View the Data Sources properties. Note that the report is using the AdventureWorks shared data source.

Note: The answers to the practices and labs are on the Student Materials CD.

Lab Shutdown After you complete the lab, you must shut down the 2793A-MIA-SQL-01 virtual machine and discard any changes.

Important: If the Close dialog box appears, ensure that Turn off and delete changes is selected, and then click OK.

Page 58: 2793A-ENU_TrainerWorkbook
Page 59: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports

Table of Contents Module Overview 2-1

Lesson 1: Creating a Basic Table Report 2-2 Lesson 2: Formatting Report Pages 2-11 Lesson 3: Calculating Values 2-17 Lab: Creating a Simple Report 2-25

Page 60: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 61: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-1

Module Overview

Objectives After completing this module, you will be able to:

• Create a basic table report. • Format report pages. • Calculate values for a report.

Page 62: 2793A-ENU_TrainerWorkbook

2-2 Module 2: Authoring Basic Reports

Lesson 1: Creating a Basic Table Report

Objectives After completing this lesson, you will be able to:

• Describe the Report Definition Language. • Describe the options for authoring a report. • Access data. • Create a table. • Create a group.

Page 63: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-3

Report Definition Language

A report definition contains data retrieval and layout information for a report. RDL is an XML representation of this report definition. Because RDL defines a report independently of the authoring tool, you can create reports by using Report Designer or any third-party tool that supports the RDL schema. Report Designer automatically translates between the graphical representation of the report layout and RDL.

Key Points • RDL is an open schema with which developers can extend RDL with additional

attributes and elements. • RDL defines a common schema to promote the interchange of report definitions.

• The RDL for a particular report is validated by using an XML schema definition (XSD). The XSD defines the accepted elements of the XML document. When a report is published by using Report Designer, the XSD is used to validate the report. You can only publish valid reports to a Report Server.

• Developers can extend and add custom functionality. The <Custom></Custom> element can be used to insert any XML structure into the RDL document.

• RDL is designed to be output-format neutral. This means that a report written in RDL can be rendered in any of several output formats including HTML, Microsoft® Excel® format, and others.

Page 64: 2793A-ENU_TrainerWorkbook

2-4 Module 2: Authoring Basic Reports

Options for Authoring a Report

Because RDL defines a report independently of the authoring tool, reports can be created using Report Designer, Report Builder, or any third-party tool that supports RDL.

Key Points • The most powerful way to design reports is to use Report Designer, which is included

as part of a client installation of Reporting Services. In Report Designer, you can create a report in three different ways: • Create a blank report and manually add queries and layout by using the following

steps:

i. Create a new report project contained within a Microsoft Visual Studio® .NET solution.

ii. Create a data source to provide a connection to the underlying data source.

iii. Create a data set. This is an SQL query that defines the data items that are available to the report from the data source.

iv. Choose a data region type, add it to the report, and then provide the data region with relevant fields from the data set.

v. Determine grouping and aggregate values. For example, you can group data into categories and subcategories, with relevant summary calculations.

vi. Optionally, add formatting to enhance the look of the report. You can use conditional formatting to highlight certain data values.

• Use Report Wizard, which automatically creates a table or matrix report based on information you provide.

Page 65: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-5

• Import an existing report from Microsoft Access.

• Report Builder is a report creation tool that has been designed for business users rather than developers. Users can use Report Builder to create reports based on a report model, which is created by a developer to provide an abstraction layer between the Report builder tool and the underlying data sources. The .NET Framework’s ClickOnce deployment mechanism provides deployment of Report Builder across an intranet or the Internet.

• You can edit RDL by using any text editor or a third-party tool designed for editing Reporting Services reports. You can then deploy the report file by using Report Manager.

Page 66: 2793A-ENU_TrainerWorkbook

2-6 Module 2: Authoring Basic Reports

Accessing Data

A Reporting Services data source contains information about a connection to a database. This includes such information as a server name, a database name, and user credentials. A Reporting Services data set contains information about the query to be used by a report. The fields contained in a data set are used as the basis for creating a report.

Key Points • A data source represents a connection to an external data source. Data sources have

the following characteristics: • A data source can be used to access data from any .NET-managed data provider.

Reporting Services directly supports Microsoft SQL Server™ 7.0 or later, OLE DB data sources, open database connectivity (ODBC) data sources, and Oracle. A report can retrieve values from multiple data sources.

• You can store user credentials for a data source, specify that the user should be prompted for credentials when the report executes, or use the user’s Microsoft Windows® credentials when connecting to the data source.

• A data source can be one of two types:

• Shared. You can reference a shared data source in multiple reports. The data source definition for a shared data source is stored in a separate file stored on the report server. With a shared data source, you can administer the data source in a single location even if multiple reports are using the data source.

• Report-specific. This type of data source is specific to a particular report. The definition for a report-specific data source is stored within the report itself and each report would need updating if the data source changes.

Page 67: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-7

• You can modify the data source configuration after report deployment by using Report Manager.

• A data set retrieves rows of data from a data source based on an SQL query. You can construct queries by creating SQL statements or by using the Query Builder within Report Designer. Data sets have the following characteristics: • Data sets are created by queries that access data sources. A single report can

retrieve data from multiple data sets. The fields in a data set become the building blocks for creating a report.

• You create data sets queries in the appropriate query language for the source database. T-SQL and PL/SQL are two examples of such query languages.

• Data sets can be made dynamic by adding SQL parameters to the WHERE clause of the query and mapping them to report parameters.

• Each data set in a report contains a list of fields. Typically, the fields refer to columns or fields returned by the query in the data set. Fields that refer to database fields contain a pointer to the database field and a name property. You can use the name property to provide a user-friendly name in place of the name of the database field. A fields list can also contain calculated fields that contain a name and an expression.

Page 68: 2793A-ENU_TrainerWorkbook

2-8 Module 2: Authoring Basic Reports

Creating a Table

Typically, the body of a report contains repeating data retrieved from an underlying data set. A data region is a control that is capable of both displaying data in a structured fashion and displaying database fields, custom fields, and expressions. The simplest type of data region is a table. A table data region is made up of a group of cells organized into fixed columns with repeating rows. Each cell in a table contains one report item, such as a text box. The value displayed in the text box can be a string constant, a field from the current row of the data set, or a more complex expression.

Key Points • Using Report Designer, you can add fields to a table from the Datasets window or by

typing an expression in to a text box. For example, you can reference a field called SalesAmount in the fields collection by using the following expression.

=Fields!SalesAmount.Value

• You can add aggregate expressions to create totals, averages, counts, maximum, and minimums values. For example, a Sales Amount Total field could contain the expression.

=Sum(Fields!SalesAmount.Value)

Page 69: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-9

Creating Groups

Table data regions provide a grouping mechanism that enables the display of detail rows, as well as header and footer rows for each grouping level contained within the report. Reports can therefore contain multiple levels of totaling.

Key Points • The default table consists of a table header row, a detail row, and a table footer row.

• The detail row shows a matching row from the data set. For example, in a report of products this row would display details of a single product, and the report would contain multiple detail rows, one for each product in the data set.

• You can add header and footer rows for categories and subcategories. Categories and subcategories provide grouping of detail rows based on values in other fields. For example, a product report could aggregate the total sales for a product category such as Electronics. All electronic products would be displayed within the same part of the table, and the total sales would be displayed in the footer of the group.

• You can create a header and footer for the entire table. This allows you to place numeric fields in the table header or footer row to summarize values from all the rows of the data set, giving a grand total. In a product report example, this could show the sum total of all sales of all products.

• Table columns make it easy to create reports where captions and summary values align vertically, but they also can be more rigid than you may prefer. There are two ways to make column alignment less rigid:

Page 70: 2793A-ENU_TrainerWorkbook

2-10 Module 2: Authoring Basic Reports

• Merging cells. You can merge two or more adjacent cells in a single row to span the original columns. This enables you to use longer text for headings at some grouping levels or to center a caption across multiple columns.

• Cell padding. Padding is the minimum space between the edge of a text box and its contents. By changing the padding, you can create a more attractive and readable layout of your rows.

Page 71: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-11

Lesson 2: Formatting Report Pages

Objectives After completing this lesson, you will be able to:

• Describe the report page options. • Format report items. • Format headers and footers.

Page 72: 2793A-ENU_TrainerWorkbook

2-12 Module 2: Authoring Basic Reports

Report Page Options

You can customize the way a report looks with a variety of different layout options, including report headers and footers, page height and width, and page breaks.

Key Points • A report can contain a header and footer that run along the top and bottom of each

page. Headers and footers can contain text, images, and other report items, but they cannot contain data regions, subreports, or an item that refers directly to a field. In Report Designer, you can enable or disable page headers and footers by using the appropriate item within the Report menu. • By default, page headers and footers appear on the first and last page of a report,

as well as each report page in between. You can disable these options by using the General tab of the Report Properties dialog box or directly within the Properties window.

• One of the most common uses for a footer is to display a page number. To display a page number in the footer of a report, create a text box in the footer and add the following expression.

="Page " & Globals.PageNumber

• When you print a report to PDF or Image rendered formats, you can set the page height and width within the Layout tab of the Report Properties dialog box in Report Designer or directly in the Properties window by following these steps:

i. In the Properties window, select Report from the box that displays configurable objects.

ii. Expand the PageSize property.

Page 73: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-13

iii. Set the Width and Height values as appropriate.

• When you print a report to HTML, you can set the interactive height and width directly in the Properties window by following these steps:

i. In the Properties window, select Report from the box that displays configurable objects.

ii. Expand the Interactive Size property.

iii. Set the Width and Height values as appropriate.

• You can set page breaks to occur before or after data regions (such as tables within a report) by setting the PageBreakAtEnd or PageBreakAtStart properties of the region. Pagination will also occur automatically depending on the rendering output format, based on the relevant height and width settings previously described.

Page 74: 2793A-ENU_TrainerWorkbook

2-14 Module 2: Authoring Basic Reports

Report Items

Report items add data, structure, and formatting to a report and come in two varieties: data regions and independent items. You can add these to a report page by using the Toolbox in Report Designer.

Key Points • A data region renders data from an underlying data set. Tables and matrices provide

multiple levels of grouping within a single data region; lists provide a single grouping. You can also nest data regions within a parent data region. Data region types include the following: • List. A list presents data arranged in a free-form fashion. You can arrange report

items to create a form with text boxes, images, and other data regions placed anywhere within the list.

• Table. A table presents data in a row-by-row format. Table columns are static, but table rows expand downwards to accommodate data. You can add groups to tables to organize data by selected fields or expressions.

• Matrix. A matrix, also known as a crosstab, contains both columns and rows that expand to accommodate data. A matrix can have dynamic columns and rows, which are repeated with groups of data, and static columns and rows which are fixed. Columns or rows can be contained within other columns or rows, to group data.

• Chart. A chart presents data graphically. Examples of charts include bar, pie, and line charts, but many more styles are supported.

• Independent report items are items that are not associated with a data set. The independent item types include:

Page 75: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-15

• Line. Horizontal, vertical, or diagonal straight lines.

• Text box. Control that enables the displaying of textual information, which can involve expressions or hard-coded values.

• Image. Graphic from a file, URL, or database field used within a table. Most common compression types are supported (such as JPEG, PNG, GIF, and TIFF). You can add images to a project for sharing across all reports within the project by using the Image Wizard and choosing the Project option. When the reports in the project are published, the images are also published to the same location. You can then update this image without updating the report.

• Rectangle. Rectangular box for graphical shape or to group other items. Grouping items can make things more convenient when you format a report within Report Designer.

• Subreport. A subreport references the body of another report. Because most reports contain a data region, the subreport appears to be a data region, although technically it is an independent item.

Page 76: 2793A-ENU_TrainerWorkbook

2-16 Module 2: Authoring Basic Reports

Headers and Footers

Headers and footers give context to a report. By using them, you can provide extra information to the report viewer, such as page numbers or the report generation date.

Key Points • To create a report header or footer in Report Designer, place report items above or

below the data region in the main body of the report. Report headers and footers appear only on the first and last pages, respectively, of a report.

• Page headers and footers appear on all pages, optionally excluding the first or last page. To include page headers or footers in a report, add page header or page footer sections using the Report menu, and set the PrintOnFirstPage and PrintOnLastPage options appropriately.

• Table headers and footers appear at the beginning and end of a table. You typically use table headers to display the field captions above the data rows. You can choose to have table headers and footers repeat on new pages, so that you can create headers and footers that are the same for all pages, even if the headers and footers exclude the first or last page. To do this, set the RepeatHeaderOnNewPage and RepeatFooterOnNewPage options of the report to True.

• Group headers and footers appear at the beginning and end of grouping levels within a table. As with table headers and footers, you can choose to have group headers and footers repeat on new pages. The group header and footer, however, can each have different values, depending on current values of the grouping. To control the printing of group headers and footers, set the Repeat Group Header and Repeat Group Footer options within the Grouping and Sorting dialog box for each grouping level.

Page 77: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-17

Lesson 3: Calculating Values

Objectives After completing this lesson, you will be able to:

• Create custom fields. • Use global collections. • Describe aggregate functions. • Use common aggregate functions. • Use conditional formatting.

Page 78: 2793A-ENU_TrainerWorkbook

2-18 Module 2: Authoring Basic Reports

Creating Custom Fields

When creating a data region within a report, you can use all of the fields in the underlying data set. You can also add custom fields by using Report Designer to provide calculated values based on data fields and global data held within the report.

Key Points • Database fields originate from the query that you use to generate the underlying data

set. Field names default to those found in the data set, but you can change them by creating an alias within Report Manager. To do this, open the Datasets window and double-click the appropriate field.

• Any database fields that are referenced in calculated fields must come from the same source data set. You can reference calculated fields in the same manner as database fields. Calculated fields are evaluated for each record in the data set. For example, the following example concatenates a postal address based on two fields.

=Fields!AddressLine1.Value & " " & Fields!City.Value

Alternatively, you can build calculated fields in the underlying query by using SQL aggregate functions or simple expressions. Create aliases within the query to provide appropriate field names. This type of calculated field only has access to database values and not the global report variables found within the report. When you create a calculated field that references a field in the data set, you must match the capitalization of the source field in your calculated expression.

Tip: When creating a calculated field, if you use the wrong capitalization when you type the name of a source field, no error will be reported in the layout view, but the error will show when previewing the report.

Page 79: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-19

Global Collections

There are seven global collections that can be used to reference data values in a report. These global collections are used within report items that are capable of displaying data—for example, data regions and text boxes.

Key Points • The Fields collection contains the fields within the current data set. These fields

typically are used to display data in text boxes in a report, but they can also be used in other report items, properties, and functions. By default, items within the Fields collection have two properties: Value and IsMissing. The Value property returns the value that was retrieved for the field in the data set. The IsMissing property indicates whether the field exists in the data set. (This is useful for queries that return variable sets of fields.) The Value property of a missing field is Null.

• The Globals collection contains the global variables for the report. The members of the Global collection are as follows: • PageNumber. This variable indicates the current page number.

• TotalPages. This variable indicates the total number of pages in a report.

• ExecutionTime. This variable indicates the time and date of execution of the report.

• ReportServerURL. This variable indicates the URL of the report server on which the report has been deployed.

• ReportFolder. This variable indicates the folder in which the report is stored.

• ReportName. This variable indicates the name of the report.

Page 80: 2793A-ENU_TrainerWorkbook

2-20 Module 2: Authoring Basic Reports

• The Parameters collection contains the report parameters within the report. Report parameters can be used to pass values to an underlying query, pass values to a filter, or as variables for calculating data within the report. A report parameter text box can be presented to the user when he or she runs the report, or a report can use a default parameter and not present a choice to the user. Parameters must be named and have a defined data type.

• The ReportItems collection contains the text boxes within the report. A text box can reference values in other text boxes from within an expression. For example, to refer to the value from a text box named Category, use the following expression.

=ReportItems("Category").Value

You can refer to text boxes at the same level or at a container level. To refer to the value of the current text box, use the expression Me.Value.

• The User collection contains data about the user who is running the report. The properties of the User collection are as follows: • UserID. This property indicates the fully qualified user name (such as

MIAMI\Administrator).

• UserLanguage. This variable indicates the culture identifier for the report (such as en-US). You can use this to retrieve localized information depending on the user’s locale.

• The DataSources collection represents the data sources referenced in the report definition. This collection is only useful for published reports and values will not be displayed when previewing a report. The following example shows how to reference the AdventureWorks data source and display the full path of the shared data source on the report server.

=DataSources("AdventureWorks").DataSourceReference

• The DataSets collection represents the datasets referenced in a report definition so that report designers can access the query command used to retrieve data from a data source. This collection is rarely used directly in reports. The following example shows how to retrieve the data set query for the TopEmployees data set:

=DataSets("TopEmployees").CommandText

Page 81: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-21

Aggregate Functions

Aggregate functions enable you to return a single value from multiple rows in a data set, such as a total or an average.

Key Points • Most aggregate functions follow a pattern similar to the following for the function

arguments.

Function(Expression, Scope)

This syntax is composed of the following parts: • Expression is typically a numeric field from the data set, but it can be any valid

expression. The expression is calculated for each detail row accessed by the aggregate function.

• Scope determines which detail rows from the data set are accessed by the function. The aggregate applies only to rows that share a common value at the specified scope. The scope argument for an aggregate function allows two possibilities:

• If you omit the argument, the expression uses the current grouping level when the expression is on a group header or footer, and the lowest available grouping when the expression is used in a detail row.

• If you use the name of a grouping level, the expression uses all of the rows that have the same value for that grouping level. The grouping level name must be entered as a string (in quotation marks), it must be from the current or higher level within the report, and it is case-sensitive.

Page 82: 2793A-ENU_TrainerWorkbook

2-22 Module 2: Authoring Basic Reports

Common Aggregate Functions

Reporting Services includes a small but useful set of aggregate functions. These functions allow you to encapsulate information from a large number of rows into a single, high-level value that can be displayed on a report.

Key Points • Avg. This function retrieves the sum of all values divided by the count of non-null

values. • Count. This function retrieves the count of all non-null values. This counts all the

rows of the data source, not just distinct values. Count is useful as a denominator when you want to create a customized average, or when you want to have visibility to the number of rows in the data set.

• CountDistinct. This function retrieves the count of distinct values for a field. This function is useful when counting identifiers that can repeat. For example, if you have multiple orders for each customer, you can use CountDistinct to count the customers.

• CountRows: This function returns a count of rows within the specified scope. Unlike CountDistinct, this function counts duplicates as individual values.

• First: This function retrieves the first value from a field over the scope. This is typically the value you get from the data set if you do not use an aggregate function, but explicitly using the First function makes the intent of the expression clearer. If you reference a database field from outside the data region in a report that contains multiple data sets, you must use the First function so that you can specify the desired data set. If the data set is sorted by date, the First function can be used for retrieving the starting inventory value.

Page 83: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-23

• Last. This function retrieves the last value from a field over the scope. This can be used for retrieving the final inventory value.

• Max. This function retrieves the largest value from a field over the scope. This is useful for finding exceptions in values that cannot be summed.

• Min. This function retrieves the smallest value from a field over the scope. Similar to the Max function, Min is useful for finding exceptions.

• RowNumber. This function retrieves an identity column (an automatically incrementing integer) on the data set. The row number increments for each row of the data set, not for each row of the report. It resets to 1 when the value at the specified scope changes. The RowNumber function can be used with conditional formatting to create alternating colors for detail rows. This is the only function that can be used as a grouping expression. When used as a grouping expression, it creates a grouping for the detail rows of the report.

• RunningValue. This function accumulates the results of any aggregate function (except RowNumber or RunningValue). A generalized form of RowNumber, It can be used with CountDistinct to create alternating colors at non-detail levels.

• StDev. This function returns the standard deviation based on a sample. This is useful to determine whether higher-level averages are truly representative of detailed values. Use this version when the data is a random sample.

• StDevP. This function returns the standard deviation based on data that represents the entire population. Use this version of StDev when the data represents everyone, not just a sample (as when examining logs from transaction systems).

• Sum. This function returns a simple summation. This is the most commonly used aggregate. Be sure that the values are additive (that is, they can be logically summed). For example, prices are not additive, and inventory counts cannot be summed over time.

• Var. This function returns the variance of all non-null values of the specified expression. Technically, this is the square of StDev.

• VarP. This function returns the population variance of all non-null values of the specified expression. Technically, this is the square of StDevP.

Page 84: 2793A-ENU_TrainerWorkbook

2-24 Module 2: Authoring Basic Reports

Conditional Formatting

When formatting reports, it is sometimes useful to highlight particular occurrences of data values or ranges of values. You can use conditional formatting to achieve this.

Key Points • Conditional formatting ties report formatting to the evaluation of an expression. • Most appearance properties can include conditional formatting. Examples of

scenarios where conditional formatting is useful include: • Dynamically setting the font or background color to highlight exceptions. For

example, a report can draw attention to negative values by formatting them with a red font color or positive values by using a black font color.

• Changing the background color of alternating rows to make a long report easier to read. Alternating row colors allow the report reader to visually align row values more easily.

• For example, to conditionally format the color of a text box, you can set Color property to the following expression.

=IIF(Me.Value < 0, "Red", "Black")

Page 85: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-25

Lab: Creating a Simple Report

After completing this lab, you will be able to:

• Create a basic table report. • Add formatting to a report. • Add calculated values to a report.

Estimated time to complete this lab: 60 minutes

Lab Setup For this lab, you will use the available virtual machine environment. Before you begin the lab, you must:

• Start the 2793A-MIA-SQL-02 virtual machine. • Log on to MIAMI by using the user name Student and the password Pa$$w0rd.

Lab Scenario The AdventureWorks team has asked you to produce a Product Profitability report. You must create the report using a tabular format, and include the AdventureWorks logo. The report must incorporate the following:

• A list of product sales, grouped by product category and subcategory. • The margin achieved for each product. • Highlighting of low-margin products. • Summary totals for all grouped information.

Page 86: 2793A-ENU_TrainerWorkbook

2-26 Module 2: Authoring Basic Reports

Exercise 1: Creating a Basic Table Report In this exercise, you will create a Product Profitability report by using the AdventureWorks database. To do this, you will define a data source and data set, and then add groupings and basic formatting to a report table.

Tasks Supporting information

1. Set up the lab environment. • Run the runScripts.bat batch file in the D:\Labfiles\Starter folder.

2. Create a Reporting Services Project.

• Using Business Intelligence Development Studio, create a new Report Server project named Product Reports.

3. Create a shared data source. • Add a shared data source to the report project and name it AdventureWorksDW.

• Use the localhost server. • Use Windows Authentication. • Use the AdventureWorksDW database. • Test the connection before proceeding to the next task.

4. Create a report. • Add a new item to the project. This item should be a report named Product Profitability.

• Do not use the Report Wizard.

5. Add a dataset. • Create a dataset named DataDetail that uses the AdventureWorksDW shared data source.

• Use the following query string: Select * from vProductProfitability Where Year = 2003 and MonthNumberOfYear = 1

6. Add a table data region. • Add a table data region to the report.

7. Add fields to the detail row. • Using the Dataset window, add the following fields to the detail row of the table, adjusting the column widths as required: • Product • SalesAmount • OrderQuantity

8. Add fields to the table footer. • In the Table Footer add a Grand Total caption to the first cell, and add summary totals for the SalesAmount and OrderQuantity fields.

• Preview the report. Make any necessary adjustments before continuing.

9. Create a Product Category group.

• Add a group named table1_Category to the detail row, grouping on the following expression: =Fields!Category.Value

• Add the Category field found in the DataDetail dataset to the first cell of the Category Header row.

• In the Category footer row, add a Category Total caption to the first cell.

• Copy the SalesAmount and OrderQuantity expressions from the Table Footer and paste them into the Category Footer.

10. Create a Product • Add a group to the detail row, grouping and sorting on the following

Page 87: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-27

Tasks Supporting information

SubCategory group. expression =Fields!SubCategory.Value. • Add the SubCategory field found in the DataDetail dataset to the first

cell of the SubCategory Header row. • In the Category Footer row, add a SubCategory Total caption to the

first cell. • Copy the SalesAmount and OrderQuantity expressions from the

Table Footer and paste them into the SubCategory Footer.

11. Apply basic formatting to the table.

• Format the Sales Amount column as currency with no decimal places (C0).

• Format the Order Quantity column as numeric with no decimal places (N0).

• Set the background color of the detail row to WhiteSmoke. • Format the Table Header and Footer as follows:

• 12pt font, bold • White background • Black foreground

• Format the Category Header and Footer as follows: • 12pt font, bold • Background set to Gainsboro

• Format the SubCategory Header and Footer to use 11pt font, bold

12. Indent row captions. • Set the left padding for the Detail, SubCategory Header, and Footer caption cells to 12pt.

• Preview the report. Make any necessary adjustments before finishing.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 88: 2793A-ENU_TrainerWorkbook

2-28 Module 2: Authoring Basic Reports

Exercise 2: Formatting Report Pages In this exercise, you will apply additional formatting to the report that you created in Exercise 1. You will add headers and footers, images, and page breaks.

Tasks Supporting information

1. Open the Product Reports solution.

• Using Business Intelligence Development Studio open the Product Reports solution located in the D:\Labfiles\Starter\Product Reports folder.

• You can omit this step if you already have the Product Reports project open from Exercise 1.

2. Add a page break at the end of each category group.

• Open the Product Profitability report. • Edit the Category Footer group so that a page break is inserted at the

end of each Category.

3. Add a report header to the first page of the report.

• Move the table item down the page so that there is approximately a 1.5 inch (4 cm) gap at the top of the report.

• Add a 12pt horizontal line to the top of the report. • Add a textbox to the top left corner.

• Adjust the width to 2.5 inches (6 cm) wide. • Adjust the height to 1.25 inches (4 cm) high. • Add the report title: Adventure Works Product Profitability

Report. • Set the font size to 20pt, bold.

4. Add an image to the report. • Add an image to the right of the report title. • Use the logopart.jpg image located in the D:\Labfiles\Starter folder. • Name the image logopart.

5. Add a repeating table header. • Alter the Table Header, setting the RepeatOnNewPage property to True.

• Preview the report. Check that the product header appears on each page.

6. Add a page header to the report.

• Add a page header to the report. • Add a textbox to the page header.

• Adjust the width to 2 inches (5 cm) wide. • Adjust the height to 0.25 inches (0.5 cm) high. • Move the textbox to the right edge of the report. • Add the text: Product Profitability Report. • Set the textbox alignment to Right.

• Alter the following properties of the page header: • Set PrintOnFirstPage to False. • Set PrintOnLastPage to True.

7. Add a page footer to the report.

• Add a page footer to the report. • Add a textbox to the page footer.

• Adjust the width to 1.5 inches (4 cm) wide. • Adjust the height to 0.25 inches (0.5 cm) high.

Page 89: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-29

Tasks Supporting information

• Using an italic font, add the text: Company Confidential. • Horizontally center the textbox relative to the report page.

• Ensure that the following page footer properties are set: • PrintOnFirstPage: False. • PrintOnLastPage: True.

• Preview the report. Check the following: • Each category is on a different page. • Table header and page footer are repeated on all pages of the

report. • The page header appears on all pages except the first page.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 90: 2793A-ENU_TrainerWorkbook

2-30 Module 2: Authoring Basic Reports

Exercise 3: Adding Calculated Values In this exercise, you will add calculated values to your report. You will also use conditional formatting.

Tasks Supporting information

1. Open the Product Reports solution.

• Using Business Intelligence Development Studio open the Product Reports solution located in the D:\Labfiles\Starter\Product Reports folder.

• You can omit this step if you already have the Product Reports project open from Exercise 1.

2. Create and add a calculated field for the profit margin.

• Open the Product Profitability report. • Using the Datasets window, add a new field to the DataDetail

dataset. • Set the name to Margin. • Select Calculated Field. • Add the following expression:

=Fields!SalesAmount.Value - Fields!CostAmount.Value

3. Add the Margin calculated field to the report.

• Insert a column to the right of the Order Quantity column. • Using the new column:

• Add the Margin field to the detail row. • Add the Margin field to the SubCategory Footer row. • Copy the expression from the SubCategory Footer row and paste

it into the Category Footer row, and the Table Footer row. • Set the Format property of the column to C0.

• Preview the report. Make any necessary adjustments before continuing.

4. Add a margin percentage expression to the detail row.

• Insert a column to the right of the Margin column. • Using the new column:

• In the Table Header row, type Margin %. • Set the Format property of the column to P1. • Enter Type the following expression in the Detail row:

=ReportItems!Margin.Value / ReportItems!SalesAmount.Value

• Preview the report. Make any necessary adjustments before continuing.

5. Add a margin percentage expression to the table footer.

• Using the Table Footer row: • In the Sales Amount cell, set the Name property to

SalesAmount_Total. • In the Margin cell, set the Name property to Margin_Total. • In the Margin % cell, add the following expression:

=ReportItems!Margin_Total.Value / ReportItems!SalesAmount_Total.Value

• Preview the report. To view the Margin % Table Footer, navigate to the end of the report.

6. Add a margin percentage • Using the Category Footer row:

Page 91: 2793A-ENU_TrainerWorkbook

Module 2: Authoring Basic Reports 2-31

Tasks Supporting information

expression to the Category footer.

• In the Sales Amount cell, set the Name property to SalesAmount_Category.

• In the Margin cell, set the Name property to Margin_Category. • In the Margin % cell, add the following expression:

=ReportItems!Margin_Category.Value / ReportItems!SalesAmount_Category.Value

• Preview the report. Notice that a margin percent exists for each category.

7. Add a margin percentage expression to the SubCategory footer.

• Using the SubCategory Footer row: • In the Sales Amount cell, set the Name property to

SalesAmount_SubCategory. • In the Margin cell, set the Name property to

Margin_SubCategory. • In the Margin % cell, add the following expression:

=ReportItems!Margin_SubCategory.Value / ReportItems!SalesAmount_SubCategory.Value

• Preview the report. Notice that a value for margin percent now exists at subcategory level.

8. Conditionally format rows with low margin percents.

• Add the following expression to the Detail row of the Margin % column: =IIF(Me.Value<0.15, "Red", "Black")

9. Copy conditional formatting to additional rows.

• Using the Margin % column: • Use the Properties window to copy the expression in the Color

property of the Detail row. • Paste the expression into the Category Footer and Table Footer

rows. • Alter the expression in the Table Footer row, replacing "Black"

with "White".

10. Sort products in descending order of Sales Amount.

• Add a group to the detail row. • Name the group DetailSort. • Group on the following expression:

=Fields!Product.Value • Sort on the following expression:

=Fields!SalesAmount.Value • Set the sort to Descending. • Preview the report. Notice that the products are listed in descending

order based on sales amount.

11. Show cumulative Sales Amount within SubCategory.

• Insert a column to the right of the Sales Amount column. • Using the new column:

• In the Table Header row, type Cumulative. • Type the following expression in the Detail row:

=RunningValue(Fields!SalesAmount.Value, Sum, "table1_SubCategory")

• Preview the report. Notice the Cumulative value increases within each subcategory until it matches the total for the subcategory.

Page 92: 2793A-ENU_TrainerWorkbook

2-32 Module 2: Authoring Basic Reports

Tasks Supporting information

12. Convert the Cumulative value to a percentage.

• Using the Cumulative column: • Edit the expression in the Detail row as follows:

=RunningValue(Fields!SalesAmount.Value, Sum, "table1_SubCategory") / ReportItems!SalesAmount_SubCategory.Value

• Set the Format property of the column to P1. • Change the label in the Table Header row to Cumulative %. • Preview the report and make any adjustments as necessary.

Notice that the cumulative percentages accumulate to 100% for each subcategory and then restart with each new subcategory.

Note: The answers to the practices and labs are on the Student Materials CD.

Lab Shutdown After you complete the lab, you must shut down the 2793A-MIA-SQL-02 virtual machine and discard any changes.

Important: If the Close dialog box appears, ensure that Turn off and delete changes is selected, and then click OK.

Page 93: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports

Table of Contents Module Overview 3-1

Lesson 1: Interactive Navigation 3-2 Lesson 2: Displaying Data 3-7 Lab: Enhancing a Report 3-17

Page 94: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 95: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-1

Module Overview

Objectives After completing this module, you will be able to:

• Create reports with interactive navigation. • Display data in various formats.

Page 96: 2793A-ENU_TrainerWorkbook

3-2 Module 3: Enhancing Basic Reports

Lesson 1: Interactive Navigation

Objectives After completing this lesson, you will be able to:

• Use dynamic visibility. • Create a document map. • Initiate actions.

Page 97: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-3

Using Dynamic Visibility

By using dynamic visibility, you can create a report that enables the user to show or hide the detail it contains. You can hide any report item based on the contents of other report items including groups, columns, or rows in a table or matrix.

Key Points • Hidden report items enable the user to toggle between summary and detail views

(“drilling down”). When the report is rendered, the user can click the text box to expand and collapse the detail data.

• Follow these steps in Report Designer to create this drill-down effect: 1. Select the group, column, or row to hide.

2. Set its hidden state to True.

3. Set the toggle item to the name of a text box in a containing group.

• Depending on the rendering format chosen, hidden items may or may not be shown in the report. For example, when rendering reports, Hypertext Markup Language (HTML) will render show-and-hide toggles on report items and not render hidden items, whereas Extensible Markup Language (XML) will render all report items, regardless of whether they are hidden.

Page 98: 2793A-ENU_TrainerWorkbook

3-4 Module 3: Enhancing Basic Reports

Creating a Document Map

Reports can contain large amounts of data that can be difficult to display effectively to a user. Users will not use a report if they find it too difficult to work with. To improve this situation, you can create a document map to improve navigability.

A document map appears as a table of contents for the report and provides links to particular areas of the report. To create a document map, add a Document Map label to a grouping level. When you render the report, the document map is automatically generated.

Key Points • When you view an HTML, Microsoft® Excel®, or Portable Document Format (PDF)

report, a document map is displayed along the side of the report. Clicking an item in the document map refreshes the report and displays the area of the report that corresponds to the clicked item. Document maps are rendered for different formats as follows: • HTML: The document map appears as a panel on the left side of the document.

• Excel: The document map appears as a worksheet that contains a navigable tree structure, which hyperlinks to the actual data.

• PDF: The document map is generated as a set of bookmarks.

• Most other outputs, including TIFF files and printed documents, ignore the document map.

• All report items contain a Document Map label property. If any report items have a Document Map label, a document map is automatically generated when a user views the report in HTML Viewer or Adobe Acrobat Reader. Data regions and independent report items can appear in a document map.

Page 99: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-5

Initiating Actions

You can add links to a report to help users navigate to particular areas of a report, to other resources located on the report server, or to resources located elsewhere that are identified by a valid URL.

Key Points • Hyperlinks in text boxes and images enable the user to jump to a particular URL. A

hyperlink can link to a static URL resource or an expression that evaluates to a URL. To create dynamic hyperlinks, URLs can be stored in a database and rendered in a data region.

• Drill-through report links allow you to link reports together. Where a parameter is specified, the target report may be filtered using the passed parameter. Drill-through reports commonly contain details about an item that is contained in an original, separate summary report. Any report that is stored on the report server can be a drill-through report. You can only add drill-through links to text boxes and images. For example, you could link product numbers contained in a sales summary report to a product report, allowing the user to "drill through" to product information from the summary report.

• A bookmark link is a link that a user clicks to move to another area or page in a report. As with all interactive features, the behavior of links is dependent on the rendering engine. HTML supports all three link types. Setting up a bookmark link is a two-step process: 1. Add a bookmark to a report item. This should be the destination report item. All

report item types may be bookmarked.

Page 100: 2793A-ENU_TrainerWorkbook

3-6 Module 3: Enhancing Basic Reports

2. Add a bookmark link to the report item you want the user to click to jump to the bookmark created in step 1. Bookmarked links can only jump to text boxes and images.

Page 101: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-7

Lesson 2: Displaying Data

Objectives After completing this lesson, you will be able to:

• Describe the various report data regions. • Create a report with tables. • Create a report with charts. • Create a report with matrices. • Work with data regions. • Create subreports.

Page 102: 2793A-ENU_TrainerWorkbook

3-8 Module 3: Enhancing Basic Reports

Data Regions

A data region is a report item that displays repeating data. The choice of data region type is dependent on the structure of the underlying data set and the way in which data is to be displayed in the report.

Key Points • The report body or rectangle allows you to add other data regions or items such as

text boxes in a free-form style. They do not support grouping directly, but contained data regions can support grouping.

• List data regions are a free-form container data region, which means that they can contain multiple items, freely arranged. A list has a single grouping level, but you can nest a list within a list to achieve multiple grouping levels.

• Table and Matrix data regions are fixed container data regions, which mean that a single cell of a table or matrix can contain only a single report item. A table can have multiple grouping levels, but only on the rows axis. A matrix can have multiple grouping levels on both the rows and columns axes.

• Chart data regions graphically represent data series. These data regions are not containers and therefore do not contain report items. A chart has a single grouping level that is dynamically created.

Page 103: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-9

Tables

A table is an effective way to display data that has a fixed set of columns with recurring detail rows. The Table data region contains other report items in a fixed manner—that is, each cell of the table can contain only one report item. This makes it easy to align columns of numbers and labels. Each cell in a table contains a text box by default. You can type any expression into any cell, or you can change the report item within the cell to another item.

Key Points • The Table data region allows you to add multiple levels of grouping, but for rows

only. The definition of values on rows changes based on the current contents of the data set. Columns are fixed.

• You can use the following column formatting techniques to alter the appearance of tables: • Padding: Adjusts the space between the edge of a cell and its contents.

• Merge cells: Combines two or more adjacent cells into one cell.

• Insert a rectangle report item into a cell, and then insert free-form report items into the rectangle.

Page 104: 2793A-ENU_TrainerWorkbook

3-10 Module 3: Enhancing Basic Reports

Charts

The Chart data region displays a graphical representation of data in a report. You can add different types of charts to a data region, and you can specify values as well as category and series groups. Charts can include different colors, symbols, and 3D effects.

Key Points • Data for charts in Reporting Services are organized into three areas:

• Values. A chart must include at least one data value series. Values determine the size of the chart element for each category group.

• To display a single chart element for each category group, define a single value series and no series groups.

• To display a chart element for each value series, define multiple values. If there are multiple value series, the chart legend displays the name of each value series.

• If you want to group data by category, you must use an aggregate expression for the value expressions in the chart.

• Category Groups. Category groups are used to group data. Categories provide the labels for chart elements. For example, in a column chart (described below), a category label is displayed on the X-axis for each set of columns. You can nest category groups. When you define multiple category groups, each category is nested within another category.

• Series Groups. You can optionally use series groups to add an additional dimension of data to a report. Using a series group produces one chart element for each value in the group. When combined with categories, this can result in a

Page 105: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-11

large number of chart elements. For example, in a column chart that displays sales by product, you can add a series group to display sales by year for each product.

• Reporting Services supports the following chart types: • Column. A column chart displays vertical columns grouped by category.

Column height indicates value. Category labels are displayed on the X-axis.

• Bar. A bar chart displays sets of horizontal bars grouped by category. Bar length indicates value. Category labels are displayed on the X-axis.

• Line. A line chart displays values as a set of points connected by a line. Category labels are displayed on the X-axis.

• Pie and Doughnut. A pie chart and a doughnut chart each display value data as percentages of the whole. Categories are represented by individual slices.

• Scatter. A scatter chart displays series as a set of points. Categories are represented by different points in the chart.

• Bubble. A bubble chart displays series as a set of symbols. Values are represented by the position of the symbol in the chart space and the size of the symbol. Categories are represented by different symbols in the chart.

• Area. An area chart displays series as a set of points connected by a line, with an area filled in below the line. Values are represented by the height of the point as measured by the Y-axis. Category labels are displayed on the X-axis.

• Stock. A stock chart displays series as a set of lines with markers for high, low, close, and open values. Values are represented by the height of the marker as measured by the Y-axis. Category labels are displayed on the X-axis.

Page 106: 2793A-ENU_TrainerWorkbook

3-12 Module 3: Enhancing Basic Reports

Lists

Table data regions do not always provide the necessary functionality for your report design as they always appear in a tabular format. However, creating a List data region provides an alternative that is not fixed in its format and is therefore suitable for creating invoices or purchase orders.

Key Points • A List data region is a free-form container that permits the placement of report items

anywhere within the list. The list repeats for each group or row in the underlying data set. A list can be used for free-form reports or in conjunction with other data regions. The List data region provides more flexibility than other kinds of data regions, such as the Table data region. However, the report author has to manually position each report item required in the list, and lists therefore take more effort to format.

• In a list, you can display detail data with one instance of the list rectangle for each row of the detail data set, or a grouping level with one instance of the list rectangle for each unique combination of values for the grouping. Unlike a table, a list allows only a single grouping. If you want to display multiple grouping levels, nest one list inside another.

Page 107: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-13

Matrices

The Matrix data region displays data as a series of columns and rows. As opposed to tables, columns in a matrix can be dynamic. Using Report Designer, you can define matrices that contain static and dynamic rows and columns.

Matrices are also known as pivot tables or crosstabs. An example of a matrix report is a sales report that shows sale totals for a list of countries in specific years. Because the list of years could change, a normal table layout would not provide the dynamic creation of columns that a matrix provides.

Key Points • In addition to creating automatic rows and columns based on data set values, you can

also add static rows or columns using the Matrix data region. Static columns are similar to the fixed columns of a table report. Static rows or columns make it possible to add more than one aggregation for a single numeric field. For example, you can add an aggregation to calculate the standard deviation of sales amount, as well an aggregation to calculate the sum of sales amount. Alternatively, you can also use static rows or columns to add different numeric fields—for example, sales amount and order quantity.

• In a matrix, there is no detail level. Even at the lowest level, you create a grouping level and use an aggregate function. The aggregate function you specify for the most detailed data is automatically used for all higher levels. By default, a matrix shows value only for the lowest visible level. To show totals for a higher level, you must add a subtotal. Subtotals are added one level at a time, on both rows and columns. To add a subtotal to a group, right-click the group column or row header and then click Subtotal.

Page 108: 2793A-ENU_TrainerWorkbook

3-14 Module 3: Enhancing Basic Reports

When you add a subtotal to a level, the label for that level displays a green triangle in the top right corner of the cell. Click the green triangle to select the subtotal field in the Properties window. With the subtotal selected, you can format the subtotal cell and decide whether the subtotal should come above or below the detail values.

Page 109: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-15

Working with Data Regions

When you work with data regions, you should consider the nesting, rendering, and sorting of data regions in a final report.

Key Points • You can nest data regions to allow the display of the same data region multiple times

in a report. For example, a sales order data report may repeat a single sales order table once for each employee. Nested data regions must use the same underlying data set. If you wish to create nested groupings with different data sets, you must use a subreport.

• A data region is only rendered if it contains data. If no data is returned, a text box containing the value of the NoRows property is displayed. NoRows can be set by using Report Designer.

• In some rendering formats (such as HTML) the position of other report items can change to accommodate expansion of a data region. Rectangles can be used to fix the position of a data region.

• You can apply sorting to various levels for a report. • Using an ORDER BY clause in the data set automatically sorts all data regions

relying on that data set within the report.

• Setting a sort in the Table Properties dialog box (or any other sortable data region) sorts only that data region within the report.

• By setting the UserSort properties for a caption within a data region, you can provide the user with the ability to dynamically sort the region when viewing the report by clicking on an ascending or descending icon within the caption. The report is the re-rendered with the new sort order.

Page 110: 2793A-ENU_TrainerWorkbook

3-16 Module 3: Enhancing Basic Reports

Subreports

Sometimes the detail of a report's data region is so complex that a separate report is a better option than using the previously described data region types. This is known as a subreport.

Key Points • The report that the subreport displays is stored on a report server, usually in the same

folder as the parent report. • A subreport can be repeated within data regions, using a parameter to filter data in

each instance of the subreport. • Only the body of the subreport is displayed. • The subreport data source can be different from that of the parent report. • Reports with data regions often perform better than reports that include subreports.

When you run a report that contains a subreport, the report server has to process both reports. If the report contains data regions instead, the report server processes only one report. Use subreports if you need to: • Nest groups of data from different data sources within a single data region.

• Reuse a subreport in multiple parent reports.

• Display a standalone report inside another report.

Page 111: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-17

Lab: Enhancing a Report

After completing this lab, you will be able to:

• Use dynamic visibility to show and hide detail in a report. • Use a document map to provide quick navigation to report items within a report. • Use a drill-through report link to link a summary report to a detail report • Use the List data region.

Estimated time to complete this lab: 45 minutes

Lab Setup For this lab, you will use the available virtual machine environment. Before you begin the lab, you must:

• Start the 2793A-MIA-SQL-03 virtual machine. • Log on to MIAMI by using the user name Student and the password Pa$$w0rd.

Lab Scenario The Adventure Works team has asked you to enhance a number of existing reports. You must add the functionality to provide:

• The ability to toggle between summarized and detailed views of data. • An easy way to navigate through the report. • The ability to drill through to other, related reports. • An alternative to the existing tabular report format.

Page 112: 2793A-ENU_TrainerWorkbook

3-18 Module 3: Enhancing Basic Reports

Exercise 1: Using Dynamic Visibility In this exercise, you will use dynamic visibility to enable the hide/show functionality in the Reseller Sales report. Users will then be able to easily navigate from summary data to detailed data.

Tasks Supporting information

1. Set up the lab environment. • Execute the runScripts.bat batch file in the D:\Labfiles\Starter\Exercise01 folder.

2. Open the AdventureWorks solution.

• Using Business Intelligence Development Studio open the AdventureWorks.sln solution in the D:\Labfiles\Starter\Exercise01 folder.

3. Preview the report. • Using the Preview tab view the Reseller Sales report. • Notice that the report contains detail and summarized values for

resellers, subcategories, and categories, including both header and footer summaries for subcategories and categories.

4. Hide the Reseller detail and State footer rows.

• Using the Properties window, alter the Visibility property for the Detail row. • Set the Hidden property to True.

• Using the Properties window, alter the Visibility properties for the State Total footer row. • Set the Hidden property to True.

• Preview the report. • The detailed reseller rows and state footers are now hidden.

5. Toggle the visibility of the hidden rows.

• Using the Properties window, alter the Visibility property for the Detail row. • Set the ToggleItem property to State.

• Using the Properties window, alter the Visibility property for the State Total footer row. • Set the ToggleItem property to State.

• Preview the report. • Expand Connecticut to view the resellers for this state. Notice

that the plus sign allows you to drill down and view the detailed reseller and state total footer rows.

6. Show State totals when the detail is hidden.

• In the State Total Footer row, copy the following cells: • Sales Amount • Cumulative % • Order Quantity • Margin • Margin %

• Paste the cells into Sales Amount cell in the State Header row. • Using the Properties window, alter the Visibility property for the

selected rows: • Set the ToggleItem property to State.

• Preview the report. • Expand Texas to view the resellers for this state. Notice that the

Page 113: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-19

Tasks Supporting information

data next to Texas in the state header row is now hidden when you drill down.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 114: 2793A-ENU_TrainerWorkbook

3-20 Module 3: Enhancing Basic Reports

Exercise 2: Using Document Maps The Product Catalog report contains a detailed listing of over 350 Adventure Works products. In this exercise, you will create a document map to provide a navigation mechanism for users of this lengthy report.

Tasks Supporting information

1. Open the Document Map solution.

• Using Business Intelligence Development Studio open the Document Map.sln solution located in the D:\Labfiles\Starter\Exercise02 folder.

2. Preview the report. • Preview the Product Catalog report. • Use the document map to navigate to the clothing products, and view

the product details shown in the catalog.

3. Add a label to the group in SubCategoryList

• Using the Properties window view the properties of the SubCategoryList.

• Edit the Grouping property, setting the Document map label to: =Fields!ProdSubCat.Value

4. Add a label to the group in ModelList

• Using the Properties window view the properties of the ModelList. • Edit the Grouping property, setting the Document map label to:

=Fields!ProdModel.Value

5. Save and preview the report. • Save and then preview the report. • Use the document map to navigate to the Clothing product category.

Notice that the products are now grouped by Product, SubCategory and model.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 115: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-21

Exercise 3: Initiating Actions The Order Details report uses a table to display order detail information. Adventure Works uses this report to verify the status of orders, to troubleshoot order complaints, and to answer questions from resellers. To troubleshoot reseller inquiries, they would like to be able to jump to the product detail information.

In this exercise, you will add an action in the Order Details report to jump to the Product Detail report.

Tasks Supporting information

1. Set up the lab environment • Execute the runScripts.bat batch file in the D:\Labfiles\Starter\Exercise03 folder.

2. Open the Action solution. • Using Business Intelligence Development Studio open the Action.sln solution located in the D:\Labfiles\Starter\Exercise03 folder.

3. Preview the report. • Open the Order Details report. • Preview the report. Notice that the report contains a series of orders

for a single customer.

4. Add an action to jump to report.

• Add an action to the Order cell in the Detail row. • Configure the action to jump to the Product Detail report. • Add a parameter named Product. • Set the value of the parameter to =Fields!Product.Value.

• Set the TextDecoration of the Order cell to Underline.

5. Save and preview the report. • Save and then preview the report. • Click the product named Road-650 Black, 60 in the report to jump to

the Product Detail report. Notice that the report is filtered by product number.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 116: 2793A-ENU_TrainerWorkbook

3-22 Module 3: Enhancing Basic Reports

Exercise 4: Using a List Data Region In this exercise, you will create a basic product sales report by using the List data region. Lists require more development effort from the report author, but provide a greater level of flexibility than tables.

Tasks Supporting information

1. Set up the lab environment. • Execute the runScripts.bat batch file in the D:\Labfiles\Starter\Exercise04 folder.

2. Open the Data Regions solution.

• Using Business Intelligence Development Studio open the Data Regions solution located in the D:\Labfiles\Starter\Exercise04 folder.

3. Preview the report. • Preview the Table Product Profitability report. Notice that it is a tabular report, containing a header and footer together with products grouped by Product Category and SubCategory.

4. Copy the report. • Create a copy of the report named List Product Profitability.

5. Expand the height of the report.

• Resize the report body to have a height of 5 inches (12.5 cm). • Move the table data region to the bottom of the report.

6. Add a Category List. • Add a list data region to the top of the report. • Resize to 0.75 inches (2 cm) high. • Position the top of the list to be 0.25 inches (0.5 cm) below the

top edge of the report. • Add grouping and sorting to the list data region.

• Set the name of the group to list1_Category. • Set the Group on expression to =Fields!Category.Value. • Set the Sort on expression to =Fields!Category.Value.

7. Add fields to the Category list.

• Using the DataDetail dataset, add the following fields horizontally starting in the bottom left corner of the Category list data region: • Category, 2 inches (5 cm) wide. • SalesAmount., 1.5 inches (4 cm) wide. • OrderQuantity, 1.5 inches (4 cm) wide.

• Set the format of the SalesAmount text box to C0. • Set the format of the OrderQuantity text box to N0. • Set the text format in all three text boxes to Bold.

8. Add header and footer rows. • Copy the three text boxes from the list data region and paste them both above, and below the list to form the basis of header and footer rows.

• Format all six text boxes as follows: • Font size 12. • Black background. • White foreground.

• Alter the text in the six text boxes as follows: • In the Category header text box, replace the text with Category. • In the Category footer text box, replace the text with Grand

Total.

Page 117: 2793A-ENU_TrainerWorkbook

Module 3: Enhancing Basic Reports 3-23

Tasks Supporting information

• In the SalesAmount header text box, replace the text with Sales Amount.

• In the OrderQuantity header text box, replace the text with Order Quantity.

• Preview the report. Notice that the list contains all product categories together with a grand total.

9. Add SubCategory list. • Add a list data region beneath the category list data region. • Position the top of the list to be 0.25 inches (0.5 cm) below the

category list data region. • Resize the list to the same width as the category list, and 0.25

inches (0.5 cm) high. • Add grouping and sorting to the list data region.

• Set the name of the group to list2_SubCategory. • Set the Group on expression to =Fields!SubCategory.Value. • Set the Sort on expression to =Fields!SubCategory.Value.

10. Add fields to the SubCategory list.

• Using the DataDetail dataset, add the SubCategory field to the subcategory list data region. • Position the text box 0.25 inches (0.5 cm) from the left edge

inside the subcategory list. • Resize to 1.75 inches (4.5 cm) wide.

• Copy the SalesAmount and OrderQuantity text boxes from the Category list and place them in the SubCategory list, just to the right of the SubCategory text box. • Remove bolding from the text boxes. • Adjust the horizontal alignment as required.

• Preview the report. Notice that there are two lists: the first has a header and footer and contains a list of categories; the second contains a list of subcategories.

11. Combine the Category and SubCategory lists.

• Move the subcategory list inside the category list. • Postion the subcategory list just below the row containing the

Category, SalesAmount and OrderQuantity calculated cells. • Copy the text boxes in the first row of the category list, to a new row

of text boxes under the subcategory list (so the category list should contain two duplicate rows of text boxes, one above the subcategory list, and one below it).

• Remove the SalesAmount and OrderQuantity text boxes in the first row of the category list (these values are now displayed below the subcategory list).

• Replace the expression in the first text box in the last row of the category list (just above the Grand Total cell), with the text Category Total.

12. Delete the table version of the report.

• Delete the table data region. • Save and then preview the report. • Adjust the formatting of the report as necessary.

Page 118: 2793A-ENU_TrainerWorkbook

3-24 Module 3: Enhancing Basic Reports

Note: The answers to the practices and labs are on the Student Materials CD.

Lab Shutdown After you complete the lab, you must shut down the 2793A-MIA-SQL-03 virtual machine and discard any changes.

Important: If the Close dialog box appears, ensure that Turn off and delete changes is selected, and then click OK.

Page 119: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets

Table of Contents Module Overview 4-1

Lesson 1: Defining Report Data 4-2 Lesson 2: Using Parameters and Filters 4-6 Lesson 3: Using Parameter Lists 4-14 Lab: Manipulating Data Sets 4-20

Page 120: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 121: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-1

Module Overview

Objectives After completing this module, you will be able to:

• Define report data. • Use parameters and filters. • Use parameter lists.

Page 122: 2793A-ENU_TrainerWorkbook

4-2 Module 4: Manipulating Data Sets

Lesson 1: Defining Report Data

Objectives After completing this lesson, you will be able to:

• Connect to data sources. • Query data sources.

Page 123: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-3

Connecting To a Data Source

A data source contains information about the data connection that is used within a report. This information can either be stored in the report directly or shared among several reports.

Key Points • Reporting Services supports connections to any Microsoft® .NET Framework

managed data provider. Typical connections include the following: Microsoft SQL Server™, SQL Server Analysis Services, OLE DB, Oracle, and open database connectivity (ODBC). However, there are many other types of managed providers available. Data sources do not contain any query information, only details about the connection itself. Credentials for accessing a data source should not be stored in the connection string, but rather stored using the login information in the Credentials tab within Report Designer. The connection string associated with the data source contains the server name, provider (for OLE DB and ODBC), and initial database catalog. For example, to connect to a SQL Server database named AdventureWorks on the local machine, use the following connection string.

Data Source=localhost;Initial Catalog=AdventureWorks

• You can save a shared data source to a report server and access it within multiple reports. A shared data source is saved in a separate Extensible Markup Language (XML) document in a folder on the report server, and it contains the name of the data source, the data source ID, and other information specific to the connection.

Page 124: 2793A-ENU_TrainerWorkbook

4-4 Module 4: Manipulating Data Sets

Report Designer can publish a shared data source at the same time as a report. The data source is created only once, when it is first published. To overwrite a shared data source each time the project is published, set the OverwrteDataSources property of the project to True. Shared data sources provide a convenient, centrally managed mechanism for accessing data.

• A report-specific data source is available only in the report in which it is defined. The connection can be used as the data source for multiple data sets within the report, however.

• Data source expressions allow you to define a connection string that changes depending on parameters passed to the report. To make designing the report easier, initially set the data source to normal connection string so that you can build the data set using the query builder tools. After the report layout is finalized, modify the connection string to use the expression. For example, the server the connection points to could change depending on the geographic location of the user, as shown in the following expression.

="data source=" & Parameters!ServerName.Value & ";initial catalog=AdventureWorks"

Page 125: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-5

Querying a Data Source

In order to work with a data source, you should be familiar with three different areas: the data set, query parameters, and stored procedures.

Key Points • A data set contains the query information that is used by data regions within a report.

It contains the pointer to a data source, the query, any query parameters, and information for grouping and collating the data. The query stored in the data set varies depending on the type of data source being accessed. When using a SQL Server data source, data can be retrieved by using an SQL query, a stored procedure, or a table name. Additional properties allow the data set to be configured, such as the CaseSensitivity property, which you can use to assist with collation. Use Report Designer to easily construct data sets either manually using SQL or automatically through the graphical query designer.

• You can declare parameters within a data set so that that the same query can be run multiple times using differing parameters. Report parameters frequently supply the query parameters, so the report user can choose the parameter values when the report is run. You will see examples of this later in this module.

• Stored procedures allow you to store the query in the database server rather than directly in the report. This provides greater reuse, ease of modification, and tighter security controls of the query. You will learn more about stored procedures later in this module.

Page 126: 2793A-ENU_TrainerWorkbook

4-6 Module 4: Manipulating Data Sets

Lesson 2: Using Parameters and Filters

Objectives After completing this lesson, you will be able to:

• Describe report parameters. • Use report parameters. • Use query parameters. • Use filters.

Page 127: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-7

Report Parameters

Using report parameters allows users to manipulate the data that will be contained in the report at run time. For example, they allow the display of different values to different users, or time-dependent data, such as sales for a particular month—all from a single report. Using report parameters can reduce the number of individual reports that the user will require.

Key Points • The most common way to use a report parameter is to restrict or filter the data in a

report. You can use a report parameter in the following ways: • To provide a value to an SQL parameter in a query that creates the data set for

the report. This is useful when you require that users type in an account number or PIN in order to see a report that contains their account details.

• To control a filter that limits rows after they are retrieved into the data set. This can be useful when focusing on different regions within a sales report. The user can quickly switch from one region to another, without creating a larger report.

• To navigate from one report to another, either as a subreport or as a jump to a report from an action.

• To control the data set that feeds the possible values of another report parameter, effectively creating dynamic parameter lists.

• To restrict the data or filter the report based on the Microsoft Windows® user account running the report.

• You can also use a report parameter as a local variable within the report. For example, you could calculate the appearance of text boxes or other report items by using a

Page 128: 2793A-ENU_TrainerWorkbook

4-8 Module 4: Manipulating Data Sets

parameter value in expressions. This could be used to switch the report from one color scheme to another when the report is included on different Web pages.

Page 129: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-9

Using Report Parameters

When you use report parameters, you must consider various aspects of the parameters. Some of these aspects will only affect the report author and some will affect the end user.

Report parameters are configured at design time, whereas the parameter values can be chosen at the time the report is run, entered using a mechanism such as a text box or a drop-down list. If a report has a non-optional parameter, the report will not run until the parameter is satisfied. If a default value is supplied for the non-optional parameter, then the user does not have to supply a value at run time.

Key Points • Each report parameter must have a unique name within the scope of the report. Also,

each parameter must be associated with a data type (the default is string). When a parameterized report is run in a browser, the parameter is displayed in a text box for string, integer, or float types, a pop-up calendar for date types, or radio buttons for Boolean types. You can set a prompt for the parameter so that a label is displayed next to the parameter in the rendered report. Report parameters may also be passed as part of a report's URL, as part of a Web page’s HTTP-POST collection, or as part of a scheduled execution of a report.

• You can configure parameters options including the following: • Hidden. Prevents the user from entering the parameter value, which must instead

come from another source, such as the URL.

• Internal. Specifies that the parameter cannot be set at run time.

• Allow null value. Specifies whether a value that has not been specified is acceptable.

Page 130: 2793A-ENU_TrainerWorkbook

4-10 Module 4: Manipulating Data Sets

• Allow blank value. Specifies whether the parameter can be left as an empty string.

• Multi-value. Allows multiple selections in a parameter drop-down list.

• When the parameter value is an option in a list of values, a drop-down list can be displayed within the report. You can create the data values contained in the list as a static list at design time, or as a dynamic list through the use of a separate data set.

• You can assign parameters a default value based on a static value, a query, or an expression. A default value is used when the report user does not specify a value for a parameter.

Page 131: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-11

Using Query Parameters

When using query parameters, there are two types of parameters to consider: the SQL query parameters and the report parameters.

Key Points • A query parameter restricts the data contained in the data set so that the information

displayed to the user is restricted. The report parameter is the link to the query parameter.

• Query parameters can be created as part of the SQL query in a data set. When a query is constructed that contains a query parameter, Report Designer automatically creates a corresponding report parameter. This allows the user to modify the parameter when they view the report. To add an SQL parameter to a query, use the @ symbol followed by the parameter name.

• Query parameters are stored in the Parameters collection within the report. You can reference them using the following syntax.

Parameters!ParameterName.Value

For example, if a query uses a parameter called @Office, a parameter will be available in the report called Parameters!Office.Value. User!UserID is a special global variable used in Reporting Services to identify the current Windows user. It can restrict the source query of a report or restrict the report data. In either scenario, you typically create a series of mapping tables that define the relationships between Windows users and the data that they are allowed to see. For example, in a sales performance report, you might include the salesperson’s name in the query and use the User!UserID global variable to filter the data so that a salesperson can only see their own data.

Page 132: 2793A-ENU_TrainerWorkbook

4-12 Module 4: Manipulating Data Sets

• When a query parameter is removed or renamed, the corresponding report parameter must be manually updated. If you need to manually modify or create a mapping between a query parameter and a report parameter, select the data set in the Data view, click the Edit Selected Dataset button (the ellipses), and select the Parameters tab.

Page 133: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-13

Filters

Query parameters restrict the data that a report displays. An alternative approach to restricting certain data is to use a technique called filtering.

Key Points • Filters play a role similar to query parameters, in that they both restrict the data that

will be returned to the report. The key difference, however, is in timing. With a query parameter, the row elimination occurs as the original data set is created. With a filter, the row elimination occurs after the data set is created, but before the data region is rendered.

• You can apply a filter to a data set, a data region (such as a matrix), or a grouping level. For example, a single data set can supply data to a number of data regions in a single report. By using data filters, a different filter can be applied to each data region as required while only querying the data source once.

• You create data filters for a report item within Report Designer. The Dataset dialog box includes a Filters tab where you can specify multiple filters for a single report. To filter your data, you must compare an expression against a value by using an operator. To apply filters to different locations, access the Filters tab within the appropriate dialog box for each data region or grouping level.

Page 134: 2793A-ENU_TrainerWorkbook

4-14 Module 4: Manipulating Data Sets

Lesson 3: Using Parameter Lists

Objectives After completing this lesson, you will be able to:

• Add parameters with a stored procedure. • Use dynamic parameter lists. • Add “All Items” to a parameter list. • Create a multi-select parameter list.

Page 135: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-15

Adding Parameters with a Stored Procedure

Although creating a data filter within a data set achieves the required goal of filtering data, it may not be the optimal solution. As an alternative, you can use a stored procedure to do the filtering or to provide the original data set.

Key Points • To use a stored procedure, you must set the command type for the data set to

StoredProcedure and specify the name of the stored procedure. When you access a stored procedure, you use the Generic Query Designer version of the Data tab. This prevents Report Designer from attempting to parse and interpret the SQL statement. If you want to switch from a text-based query to a stored procedure, click the Generic Query Designer toolbar button, and then click StoredProcedure in the Command type list.

• Reporting Services supports input parameters to a stored procedure. All input parameters are automatically detected and made available as report parameters or other values. Reporting Services only supports stored procedures that return a single data set.

• Using stored procedures provides you with the following benefits: • Details of the source query for data access are hidden from the report, which

gives you flexibility in creating the source for a data set and ease of modification.

• Extended logic makes it possible to take advantage of procedural logic or other techniques that are not possible in a standard query or view.

• Security configuration options that use standard SQL Server security are provided by the database server.

Page 136: 2793A-ENU_TrainerWorkbook

4-16 Module 4: Manipulating Data Sets

• You can reuse the logic within a stored procedure within multiple data sets and multiple reports.

Page 137: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-17

Dynamic Parameters Lists

A dynamic parameter list is simply a list of values for one parameter that changes dynamically based on the value you select for a different parameter. This dependency between parameters is also known as cascading parameters.

Key Points • You can create a dynamic parameter list when the source for the list is an SQL query.

Simply add a query parameter to the data set query for the report parameter, and then link that query parameter to a separate parameter.

• It is important to order the parameters so that the dependent parameter comes after the parameter upon which it is dependent. Otherwise, the dependent parameter will attempt to evaluate its list of values before the parameter that it is dependent upon is set. This would produce at best an incorrect value, and at worst an error. For example, when a report allows users to type in a country and then choose a region from within that country, a parameter named Country is specified and displayed to the user in a text box. A second parameter named Region is added to the report using a drop-down list. The Region query uses the value of the Country parameter in its query to filter the data contained in its drop-down list. The query for the Region drop-down list appears as follows.

SELECT Region FROM Geography WHERE Country = Parameters!Country.Value

Page 138: 2793A-ENU_TrainerWorkbook

4-18 Module 4: Manipulating Data Sets

Adding “All Items” to a Parameter List

Parameter lists can sometimes cause problems for the end user, because the report may not be able to display an unfiltered version of the data. In this case, you must manually implement a way to achieve this requirement.

Key Points • You can select a single item for a parameter from a parameter list. Typically, the list

of values for a parameter comes from the distinct values of a database field. Consequently, the default list does not have an option for “All Items.”

• You can add the “All Items” option for filtered data or the original data set. • Change the parameter list query to include an appropriately named item along

with a key value that will not be present in the actual database values (if a key value is required). You add this item by using a UNION operator along with a constant, single-row query, as shown in the following example that displays a list of cities with an additional [All Items] value.

SELECT '[All Items]' AS City UNION SELECT DISTINCT City FROM Person.Address

• For a parameterized data set query, change the SQL query that includes the linked query parameter to include an OR option to test for the "All Items" key as shown in the following example:

SELECT * FROM Person.Address WHERE (City = @city) OR (@city = '[All Items]')

Page 139: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-19

Creating a Multi-Select Parameter List

In some situations, you may want the user to select multiple items for report parameters. For example, you may need to display a report based on multiple months rather than a single month.

Key Points • When you design a report, it is common to supply a list of parameter values from

which the user can select. By default, the user can only choose a single item from a parameter list. However, if you specify the multi-value option for a report parameter, the user will be presented with a multi-select combo box. This will require changes to the syntax of the underlying query.

• The query needs to incorporate the parameter into an IN clause. To do this, modify the existing query’s WHERE clause to include an IN clause with a single parameter as the list. The following example shows how to achieve this.

SELECT * FROM Person.Address WHERE City IN (@city)

Page 140: 2793A-ENU_TrainerWorkbook

4-20 Module 4: Manipulating Data Sets

Lab: Manipulating Data Sets

In this lab, you will use both query and report parameters to filter data in a report. You will then enhance the user interface of the report, allowing users to select multiple items from a parameter list and display information matching all items in the parameter list.

After completing this lab, you will be able to:

• Use parameters to restrict query results. • Use parameters to filter report data. • Create a dynamic parameter list. • Pass parameters to a stored procedure. • Display data matching all categories in a parameter list.

Estimated time to complete this lab: 60 minutes

Lab Setup For this lab, you will use the available virtual machine environment. Before you begin the lab, you must:

• Start the 2793A-MIA-SQL-04 virtual machine. • Log on to MIAMI by using the user name Student and the password Pa$$w0rd.

Lab Scenario The Adventure Works team has asked you to enhance a number of existing reports. You must add the functionality to provide:

• Filtering of report data by using report parameters.

Page 141: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-21

• Dynamic parameter lists, dependent on related parameter choices. • Data sourced from a stored procedure.

Page 142: 2793A-ENU_TrainerWorkbook

4-22 Module 4: Manipulating Data Sets

Exercise 1: Using Parameters to Restrict Query Results The Product Profitability report uses a table to display total sales performance by product and summarized totals by product subcategory and category. To restrict data in the report by month and year, you will create hard-coded parameters to filter the report.

Tasks Supporting information

1. Set up the lab environment. • Execute the runScripts.bat batch file in the D:\Labfiles\Starter\Exercise01 folder.

2. Open the Data Manipulation solution.

• Using Business Intelligence Development Studio open the Data Manipulation.sln solution in the D:\Labfiles\Starter\Exercise01 folder.

• Open and preview the Product Profitability.rdl report.

3. Modify the data set query. • Modify the DataDetail dataset, replacing the year and month constant values with parameters.

• The WHERE clause of the query should look like this: WHERE (Year = @Year) AND (MonthNumberOfYear = @Month)

4. Edit the Year and Month parameters.

• Click Report Parameters on the Report menu while viewing the Layout tab to edit the report’s parameters.

• Edit the Year report parameters as follows: • Set the Default values to a non-queried value of 2003.

• Edit the Month report parameters as follows: • Set the Available values to a non-queried value. Use the

following labels and values: Label Value Jan 1 Feb 2 Mar 3 Apr 4 May 5 Jun 6

• Set the Default values to a non-queried value of 1.

5. Save and preview the report. • Save and then preview the report. • Verify that a Year text box and a Month drop-down list appear at the

top of the report. • Close the solution.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 143: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-23

Exercise 2: Using Parameters to Filter Report Data In this exercise, you will use a parameter to filter the report data by category rather than filtering the actual data source, as you did in the previous exercise.

Tasks Supporting information

1. Open the Data Manipulation solution.

• Using Business Intelligence Development Studio open the Data Manipulation.sln solution in the D:\Labfiles\Starter\Exercise02 folder.

• Open the Product Profitability report.

2. Add a data set for the Category parameter.

• Create a new dataset named Category. • Set the data source to AdventureWorksDW, and use the following

query: SELECT DISTINCT EnglishProductCategoryName AS Category FROM DimProductCategory

3. Create the Category parameter.

• Click Report Parameters on the Report menu while viewing the Layout tab to edit the report’s parameters.

• Add a new report parameter. • Edit the new report parameters as follows:

• Set the Name and Prompt to Category. • Clear the Allow blank value check box. • Set the Available values to a queried value, using the Category

dataset. Use the Category field for both the Value and Label. • Set the Default values to a non-queried value of Components.

4. Add a filter to the table data region.

• Edit the properties of the table data region. • On the Filters tab:

• Add a filter expression as follows: =Fields!Category.Value. • Set the Operator to equals. • Add an expression for the Value as follows:

=Parameters!Category.Value

5. Remove the Category group page break.

• In the table data region, edit the Category footer. • Clear the Page break at end option.

• Preview the report. Verify the Category parameter, defaults to the Components category.

6. Add the Category to the report header.

• Add a text box to the report, just above the graphic. • Edit the expression property of the text box, setting the expression to:

=Parameters!Category.Value. • Preview the report. Verify the value of the Category parameter is now

displayed above the graphic.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 144: 2793A-ENU_TrainerWorkbook

4-24 Module 4: Manipulating Data Sets

Exercise 3: Creating Dynamic Parameter Lists The Product Details report uses a table to display product detail information. The report is filtered by a product subcategory report parameter.

In this exercise, you will create a dynamic parameter list to filter the report based on both the product category and subcategory.

Tasks Supporting information

1. Open the Dynamic Parameters solution.

• Using Business Intelligence Development Studio open the Dynamic Parameters.sln solution in the D:\Labfiles\Starter\Exercise03 folder.

• Open and preview the Product Details report. • Notice that the SubCategory parameter is used to restrict data in

the report. • The default value for the SubCategory parameter is Mountain

Bikes.

2. Add a data set for the Category parameter.

• Create a new dataset named Category. • Ensure the data source is set to DataSet1, and use the following

query: SELECT ProductCategoryID, Name FROM Production.ProductCategory

• Verify the query. Correct any errors before continuing.

3. Modify the SubCategory data set query.

• Modify the SubCategory data set. • Add the following WHERE clause to the end of the SQL query:

WHERE (ProductCategoryID = @ProductCategory) • The SQL query should appear as follows:

SELECT ProductSubcategoryID, ProductCategoryID, Name FROM Production.ProductSubcategory WHERE (ProductCategoryID = @ProductCategory)

4. Modify the ProductDetail data set query.

• Modify the ProductDetail data set. • In the Grid pane, in the first blank Column cell, click

PS.ProductCategoryID. • In the Filter Column of the ProductCategoryID row, type

= @ProductCategory. • Save the project.

5. Edit the ProductCategory parameter.

• Click Report Parameters on the Report menu while viewing the Layout tab to edit the report’s parameters.

• Edit the ProductCategory parameter as follows: • Move ProductCategory above SubCategory. • Set the Available values to a queried value, using the Category

dataset. Use the ProductCategoryID field for the Value, and the Name field for the Label.

• Set the Default values to a non-queried value of 1.

6. Set the title of the report. • Edit the expression contained in the report name text box. • Set the expression to:

=Globals!ReportName + " for " & Parameters!ProductCategory.Label

Page 145: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-25

Tasks Supporting information

• Save the solution. • Preview the report.

• Select the Clothing ProductCategory. • Notice that the SubCategory parameter is a dynamic parameter

list dependent on the ProductCategory parameter. • Select the Shorts SubCategory.

• Close the solution.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 146: 2793A-ENU_TrainerWorkbook

4-26 Module 4: Manipulating Data Sets

Exercise 4: Using Parameters with a Stored Procedure In this exercise, you will use a stored procedure named sp_ActualVsQuota to supply the data for a report. You will set up two input parameters to control the data set; CalendarYear and Group.

Tasks Supporting information

1 Set up the lab environment. • Execute the runScripts.bat batch file in the D:\Labfiles\Starter\Exercise04 folder.

2 Open the Stored Procedure solution.

• Using Business Intelligence Development Studio open the Stored Procedure.sln solution in the D:\Labfiles\Starter\Exercise04 folder.

• Open the Actual Vs Quota report.

3. Create a stored procedure data set.

• Create a new data set named Detail. • Use the AdventureWorksDW (shared) data source. • Set the command type to StoredProcedure. • Use the sp_ActualVsQuota stored procedure.

• Test the data set by running it with the following parameters: • @CalendarYear 2003 • @Group Europe

4. Edit report parameters. • Click Report Parameters on the Report menu while viewing the Layout tab to edit the report’s parameters.

• Edit the CalendarYear parameter as follows. • Set the Available values to non-queried. • Set the Default values to a non-queried value of 2003.

• Edit the Group parameter as follows. • Set the Available values to non-queried. • Set the Default values to a non-queried value of North

America.

5. Save and preview the report. • Save and preview the report by using a value of Europe for the Group parameter.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 147: 2793A-ENU_TrainerWorkbook

Module 4: Manipulating Data Sets 4-27

If Time Permits: Displaying All Categories in a Parameter List In this exercise, you will create a report that allows the user the option of selecting all of the categories from the parameter list.

Tasks Supporting information

1. Open the All Items solution. • Using Business Intelligence Development Studio open the All Items.sln solution in the D:\Labfiles\Starter\Exercise05 folder.

• Open the All Items Product Profitability report. • Preview the report.

• Notice that the report contains the Category parameter, which has a default value of Accessories and a drop-down list from which you can select.

• Select and view the Bikes category. Notice that there is no way to display all categories in the same report.

2. Add all categories to the Category data set.

• Edit the Category data set. • Alter the SQL query to add the following UNION statement above

the GROUP BY statement: UNION SELECT -1, 'All Categories'

• Run the query to verify that the All Categories entry has been added to the query with a key value of -1.

3. Update the DataDetail data set query.

• Edit the DataDetail data set. • Alter the CategoryKey filter expression in the Grid pane to:

= @Category OR @Category = - 1 • Save and preview the report.

• Select All Categories and then verify that all categories are displayed in the report.

Note: The answers to the practices and labs are on the Student Materials CD.

Lab Shutdown After you complete the lab, you must shut down the 2793A-MIA-SQL-04 virtual machine and discard any changes.

Important: If the Close dialog box appears, ensure that Turn off and delete changes is selected, and then click OK.

Page 148: 2793A-ENU_TrainerWorkbook
Page 149: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models

Table of Contents Module Overview 5-1

Lesson 1: Creating Report Models 5-2 Lesson 2: Using Report Builder 5-9 Lab: Working with Report Models 5-18

Page 150: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 151: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-1

Module Overview

Objectives After completing this module, you will be able to:

• Create Report Models. • Use Report Builder.

Page 152: 2793A-ENU_TrainerWorkbook

5-2 Module 5: Using Report Models

Lesson 1: Creating Report Models

Objectives After completing this lesson, you will be able to:

• Describe a Report Model. • Describe Report Model objects and concepts. • Describe the options for creating Report Models. • Use Model Designer.

Page 153: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-3

What Are Report Models?

A report model provides a report development context in which experienced users can develop reports by using Report Builder. A report model presents data in a simplified structure and uses business-oriented language.

Key Points • A report model is a metadata layer defined on top of a physical database. The

metadata is defined in an XML language called Semantic Model Definition Language (SMDL). You can define a report model for a Microsoft® SQL Server™ database or a SQL Server Analysis Services database. • The metadata describes a business model of the data that uses names for things

that are in the language that is used by the business, and is familiar to the users. The report model also contains a physical model of the underlying database, and a mapping between the business and physical models.

• The physical model defines any relationships between items in the underlying data source so that the user does not have to manipulate data relationships directly.

• Report Builder reads the report model SMDL file and presents a business-focused drag-and-drop-style user interface in which users can design their reports.

• Report models are useful when reports will be created by information workers, rather than developers.

Page 154: 2793A-ENU_TrainerWorkbook

5-4 Module 5: Using Report Models

Report Model Objects and Concepts

Before you start to build a report model, it is helpful to review the main parts of a report model. A report model contains a business model, a physical model of the underlying data, and mapping information that relates the business model and physical model. The business model is presented to the users in business language, and is organized in entities, folders, and perspectives.

Key Points • An entity represents a logical business object, such as a product or a customer, and it

can contain source fields, expressions, roles, folders, and filters. An entity may contain a data mapping (called a binding) to a single table in the underlying data, but you can also create entities with no binding to represent a logical business subject that contains calculated values. Entities can also contain items that return data from more than one underlying table by using expressions. For example, a report model might include a Customer entity with a binding to a Customers table in a database.

• An attribute describes a property of an entity, and can be added as a source field type or an expression type. A source field type attribute may contain a binding to a single column in the underlying data, or if the binding is omitted, an expression can be used to return data. An expression type attribute might or might not have a binding, but it must have an expression. An expression is a formula that returns data, and it can reference other attributes and use operators, functions, and constants. For example, you can create a Full Name attribute by using a text expression to join the first name and last name of a customer with a space between. In addition to its business name, an attribute also contains other presentation information, such as text alignment, number format, sort direction, and width.

Page 155: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-5

• Folders and perspectives help you to organize a report model. A folder can exist at the root level of a report model to organize entities, or inside an entity to organize attributes, roles, and filters. A folder can also exist within another folder. Folders do not provide a security mechanism for a report model. A perspective presents a sub-model to users in their own particular business area. A perspective identifies a subset of a report model that a user will connect to, and you can add both entities and attributes to a perspective. A report model can have more than one perspective.

• Report model roles define relationships between entities, and can be one-to-many or one-to-one. A role can also be defined as a lookup; this restricts the data that can be seen by the users in a related entity to a single attribute. Tools like Report Builder use roles to help report designers to navigate easily through the relationships in a report model.

• The report server automatically generates clickthrough reports for a Report Builder report. A clickthrough report displays detailed information about the data in the main report when a user clicks on a scalar value or an aggregate attribute. The report server generates one of two clickthrough report formats that depend on where the user clicks. If the user clicks a scalar value, then the Single Instance template is used; if the user clicks an aggregate attribute, then the Multiple Instance template is used. You define the list attributes to include in each of the two formats in the report model. You can create a custom report to replace the default layout of the clickthrough templates.

Page 156: 2793A-ENU_TrainerWorkbook

5-6 Module 5: Using Report Models

Options for Creating Report Models

You can create report models by using Model Designer, Report Manager, or SQL Server Management Studio.

Key Points • By using Report Manager or SQL Server Management Studio, you can generate

models based on SQL Server databases or Analysis Services cubes. Only SQL Server database-based models can be edited after creation. If your Analysis Services database structure changes, you must regenerate the model.

• Model Designer provides the most flexibility for designing models based on SQL Server databases. Using Model Designer, you can select which rules are applied during the model generation process, and you can modify the model and its underlying data source view.

Page 157: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-7

Using Model Designer

Before you can use Report Builder to design reports, you must design your Report Model. Model Designer provides the most flexible options for model creation. To design a Report Model, follow the steps listed below.

Key Points 1. Create a Report Model project. A report model project is a container for the

model and consists of one or more data source (.ds) files, one or more data source view (.dsv) files, and one or more report model (.smdl) files.

2. Create a data source. A data source file contains the information that Report Builder needs to connect to the database, such as the server name, database name, and credentials.

3. Create a data source view. A data source view document is a description of the database to which the data source file is pointing. This allows you to select different parts of the database, such as tables and views, and group them together into a view. For example, you could create a data source view for all the Customer related objects in the database, and another view for the Employee objects.

4. Define the Report Model. When the report model file is generated, entities, roles, fields, and folders are automatically created as part of the wizard process. You will probably want to refine the model before publishing it. For example, you can reorganize the model items, rename items, and add additional entities, folders, and perspectives to the model.

Page 158: 2793A-ENU_TrainerWorkbook

5-8 Module 5: Using Report Models

5. Publish the Report Model. You need to publish the entire report model project to the catalog on the Report Server so that other users can develop reports using Report Builder.

Page 159: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-9

Lesson 2: Using Report Builder

Objectives After completing this lesson, you will be able to:

• Describe Report Builder. • Use Report Builder. • Work with entities and folders. • Group and sort data. • Filter data. • View and publish a report.

Page 160: 2793A-ENU_TrainerWorkbook

5-10 Module 5: Using Report Models

What Is Report Builder?

Report Builder allows business users to create their own reports based on a user-friendly report model created in Model Designer. Report Builder is a client-based application that can run on any platform that supports the Microsoft .NET Framework version 2.0.

Key Points • Report Builder is a ClickOnce Microsoft Windows™ Forms application that runs

locally on a client machine. ClickOnce technology enables application deployment across an intranet or the Internet without any special requirements on the client apart from the .NET Framework 2.0. ClickOnce applications are completely self-contained and installed on a per-user basis. They run in a secure sandbox provided by the .NET Code Access Security model so that access to the local machine is restricted to a minimal set of permissions.

• Report Builder is a license-free development environment for ad-hoc report creation that creates .rdl files in the same format as SQL Server Business Intelligence Design Studio. This allows you to publish Report Builder reports to a Report Server so other users can view the rendered report.

• Designed for non-developers, Report Builder can be used by anyone within the business that requires a report, without any understanding of the underlying database structure.

Page 161: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-11

Using Report Builder

To create a report using Report Builder, perform the following steps.

Key Points 1. Install or start Report Builder from Report Manager by clicking the Report

Builder button.

2. Select the appropriate data source from the list of available report models.

3. Select the report type based on a table, matrix, or chart layout.

4. Create the report layout by dragging required entities or fields from the Explorer to the appropriate report area.

5. Apply groupings or filter the data.

6. Test the report locally by running the report.

7. Publish the report to a Report Server or save the RDL file locally.

Page 162: 2793A-ENU_TrainerWorkbook

5-12 Module 5: Using Report Models

Working with Entities and Folders

After choosing your data source and report type, all the contents of the selected data source appear in the Explorer pane within Report Builder. Entities contain fields, while folders contain other entities that the designer of the report model chose to group together.

Key Points • Dragging a field or entity to the design area starts the report-building process. The

entity that you select or the entity from which you selected a field becomes the primary entity.

• After you select the primary entity, entities that are not related to the primary entity do not appear in the Explorer pane, and your report is now limited to what it can display.

• In advanced mode, the Explorer pane shows additional relationships between the entities that are not typically displayed. These relationships allow you to build complex queries that use reverse roles, lookup entities, and entities that inherit from the direct ancestors of the selected entity but are not a direct ancestor of the current entity.

Page 163: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-13

Grouping and Sorting Data

Groups organize data so that the report is displayed in a visual hierarchy for obtaining subtotals. After grouping the data, you can sort the data within each group in ascending or descending order. You can also add page breaks to help make the report easier to read.

Key Points • As you drag fields and entities to the design area, you are also organizing the data

into groups. In Report Builder, groups are indicated by the group tabs that appear along the top edge of the report layout. For example, you could create a sales report that contains customer information and the sales territories that these customers are located in. You can group the data by Sales Territory and then Customer to see total sales for each territory and each customer. Two types of groups are available: • Value groups. These group on a field. When the report is run, the value group

returns a single instance of the group for each distinct value.

• Entity groups. These group on an entity. When the report is run, the entity group returns a single instance of the entity.

• You can sort data within each group by any field in the group, or any field for which subtotals are displayed. Each group can also be sorted by multiple fields.

• Page breaks determine how content fits in a report page for optimal viewing when you run the report in Report Builder or when it is rendered on the report server. Adding page breaks also improves the performance when large reports are rendered, because a rendered page is displayed while the rest of the pages are rendered in the background.

Page 164: 2793A-ENU_TrainerWorkbook

5-14 Module 5: Using Report Models

Page breaks can only be added before, after, and between groups.

Page 165: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-15

Filtering Data

Filtering allows you to limit the data displayed in your report to just the data that you are interested in viewing. In Report Builder, a filter is a set of conditions that are applied to the data at the data source level. Logical operators (such as and and or) allow you to create multiple conditions that increase the complexity of your filter.

Key Points • Choose your filter field or entity by dragging the chosen field or entity to the filter

area. You can use any available entity or field to create your filter, even if the entity or field is not displayed in the body of the report. This action creates the filter condition.

• Comparison operators are used to evaluate the filter condition for each instance of the entity to determine whether the data should be included in the report. You can choose from the following comparison operators, depending on the data type: • Is Blank

• In a List

• Greater Than

• Greater Than or Equals

• Less Than

• Less Than or Equals

• From…To

• Contains

Page 166: 2793A-ENU_TrainerWorkbook

5-16 Module 5: Using Report Models

• You can also use the Not option to indicate that only those items that do not meet the specified filter condition should be included in the report.

• The filter criterion is the value to which all items within the field or entity is compared, to determine whether the data should be excluded from the report. Depending on how your data source is set up, criteria can be specified using a variety of methods, including lists, text boxes, and calendars.

• A filter group contains one or more filter conditions connected by the same logical operator. Grouping filter conditions helps refine the data returned when the filter is applied to the report. By default, a single, implied filter group is created when you add several filter conditions to the filter area. You can also nest filter groups to create a filter hierarchy.

Page 167: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-17

Viewing and Publishing a Report

The final steps in creating a report are to test the report locally, then to publish the report for other users to see on the report server.

Key Points • To see a real representation of your report with live data, you need to run, or render,

the report. To run a report, click the Run Report button on the Report Builder toolbar. The results are displayed in the Report Builder run mode window.

• When you create a report in Report Builder, you are really creating a report definition, which is a file that contains Report Definition Language and metadata queries. When you save a report, the report definition is saved as an .rdl file on the report server from which Report Builder was launched, or locally on the file system. To save the report to the report server, click the Save button. To save the report to the local file system, click File, then click the Save to File menu item.

Page 168: 2793A-ENU_TrainerWorkbook

5-18 Module 5: Using Report Models

Lab: Working with Report Models

In this lab, you will create a report model project based on the AdventureWorks database. You will then use Report Builder to create a Customer Orders report based on the report model.

After completing this lab, you will be able to:

• Create a Report Model project. • Create a tabular report by using Report Builder.

Estimated time to complete this lab: 45 minutes.

Lab Setup For this lab, you will use the available virtual machine environment. Before you begin the lab, you must:

• Start the 2793A-MIA-SQL-05 virtual machine. • Log on to MIAMI by using the user name Student and the password Pa$$w0rd.

Lab Scenario The sales managers at Adventure Works need to be able to create their own reports to show customer sales data. The sales managers are experienced Windows users, but they are not developers and don’t want to use Business Intelligence Development Studio to create their reports. You have therefore decided to create a report model that they can use in Report Builder when they create their reports.

Page 169: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-19

Exercise 1: Creating a Report Model In this exercise, you will create a report model project containing customer and sales order data from the AdventureWorks database.

Tasks Supporting information

1. Create a Report Model project.

• Using Business Intelligence Development Studio create a new Report Model Project named AdventureWorks Report Model.

• Save the project in the D:\Labfiles\Starter\Exercise1 folder.

2. Create a Data Source. • Use the Data Source Wizard to create a Data Source. • Create a connection to MIAMI. • Use Windows Authentication. • Use the AdventureWorks database. • Set the name of the Data Source to Adventure Works.

• Test the connection before you continue.

3. Create a Data Source View. • Use the Data Source View Wizard to create a data source view. • Use the Adventure Works Data Source. • Include the Person.Contact, Sales.Customer,

Sales.Individual, and Sales.SalesOrderHeader tables. • Set the name of the Data Source View to Customer Sales.

4. Create a Report Model. • Use the Report Model Wizard to create a report model. • Use the Customer Sales.dsv data source view. • On the Select report model generation rules page, use the

rules selected by default. • On the Collect Model Statistics page, ensure that Update

model statistics before generating is selected. • Run the Customer Sales model.

• Edit the Sales Order Header entity. • Change the Name property to Sales Order. • Change the CollectionName property to Sales Orders. • Rename the #Sales Order Headers attribute to #Sales Orders.

• Save the project.

5. Publish the Report Model to a report server.

• Configure the AdventureWorks Report Model project to use a TargetServerURL of http://miami/ReportServer

• Use Solution Explorer to deploy the report model. • Using Microsoft Internet Explorer®, browse to http://miami/reports

and verify that the Customer Sales report model has been deployed to the Models folder.

Page 170: 2793A-ENU_TrainerWorkbook

5-20 Module 5: Using Report Models

Exercise 2: Using Report Builder to Create a Report In this exercise, you will use the Report Builder to create a report based on the Customer Sales model that you created in the previous exercise. You will then publish the report to a report server.

Tasks Supporting information

1. Create a tabular report. • Download and run Report Builder by clicking the Report Builder button on the Report Manager home page at http://miami/reports.

• Create a table (columnar) report that uses the Customer Sales data source.

2. Add fields and entities to the report.

• In the Explorer pane, select the Contact entity from the Entities list and add Last Name attribute to the report. • Drag the Last Name attribute to the Drag and drop column

fields area in the design area, and change the text to Name. • Edit the formula of the cell directly below the Name text box. Set

the formula for each contact to display names in the format Last Name, First Name.

• Resize the Name text box appropriately. • Select the Sales Orders entity from the Entities list and add #Sales

Orders and Total Total Due attributes to the table in the report. • Edit the Total Total Due text box and replace the text with Total

Value. • Set the format of the two table cells beneath the Total Value to

display the values as currency. • Resize the text boxes appropriately.

3. Define the sort order. • Click the Sort and Group button. • Configure a descending sort on Total Value, and then an ascending

sort on Name.

4. Define the report filter. • Click the Filter button. • Add a filter on the Order Date attribute from the Sales Order entity

to show orders from 10/1/2003 to 12/31/2003. • Add a filter on the Customer Type attribute from the Customer

entity to show customers of type I.

5. Format the report. • Add a title. • Set the title text to Customer Sales. • Set the title fill color to Cornflower. • Set the title font color to White.

• Add a filter description subtitle. • On the Insert menu, click Filter Description. • Place the filter description text box beneath the title. • Resize the filter description appropriately.

6. Run the report. • Run the report. • Notice that:

• The report is ordered by Total value, with totals shown at the end of the report.

Page 171: 2793A-ENU_TrainerWorkbook

Module 5: Using Report Models 5-21

Tasks Supporting information

• The filtering expression is shown at the beginning and end of the report.

7. Save the report to the report server.

• Save the report as Customer Sales in the Report Server Home folder.

8. View the report. • Use Internet Explorer to browse to the http://miami/reports. • On the Home page, view the Customer Sales report. • Click Vazquez, Larry. Notice that Contact entity is shown from the

report model. • Close Internet Explorer.

Note: The answers to the practices and labs are on the Student Materials CD.

Lab Shutdown After you complete the lab, you must shut down the 2793A-MIA-SQL-05 virtual machine and discard any changes.

Important: If the Close dialog box appears, ensure that Turn off and delete changes is selected, and then click OK.

Page 172: 2793A-ENU_TrainerWorkbook
Page 173: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports

Table of Contents Module Overview 6-1

Lesson 1: Publishing Reports 6-2 Lesson 2: Executing Reports 6-10 Lesson 3: Creating Cached Instances 6-17 Lesson 4: Creating Snapshots and Report History 6-23 Lab: Publishing and Executing Reports 6-33

Page 174: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 175: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-1

Module Overview

Objectives After completing this module, you will be able to:

• Publish reports. • Execute reports. • Create cached instances. • Create snapshots and report history.

Page 176: 2793A-ENU_TrainerWorkbook

6-2 Module 6: Publishing and Executing Reports

Lesson 1: Publishing Reports

Objectives After completing this lesson, you will be able to:

• Publish reports with Report Designer. • Publish reports with Report Manager. • Update data sources. • Update reports. • Configure report properties.

Page 177: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-3

Publishing with Report Designer

With the Report Designer tool provided in Microsoft® Visual Studio® 2005, you can design your reports and data sources. You can also use it to deploy reports and data sources to Report Server.

Key Points • You can use Report Designer to deploy the following units:

• Single file deployment. Deploys only a single file, such as a report or data source, to the Report Server database.

• Project deployment. Deploys all of the data sources, reports, and any other custom content in the project to the Report Server database.

• Solution deployment. Deploys all of the projects within the solution to the Report Server database.

To deploy an item, right-click the appropriate item in Solution Explorer and then click Deploy.

• You configure project deployment options by clicking Properties on the Project menu to open the report project Property Pages dialog box. You can configure the following project deployment options: • TargetServerURL. The URL of the report server that will host your items.

• TargetFolder. The folder where report items are deployed. You can select any folder or subfolder defined in the Report Server database, or you can specify a new folder for creation at the time of deployment.

• TargetDataSourceFolder. The folder where shared data sources are deployed.

Page 178: 2793A-ENU_TrainerWorkbook

6-4 Module 6: Publishing and Executing Reports

Publishing with Report Manager

Report Manager enables you to perform various deployment tasks by using your Web browser. Users who do not have Report Designer installed can use this feature to deploy reports as well as managing existing reports.

Key Points • You can use Report Manager to upload individual files to the report server, such as

reports, data sources, and resources, to a default maximum limit of 4,096 KB per item. You can modify this default by adjusting the value of the maxRequestLength attribute within the processModel element in the Machine.config file. To upload a file, open Report Manager and click Upload File. The browser then displays a page on which you can enter all necessary information.

• You can use Report Manager folders to organize content based on whatever groups are appropriate for your application. To create a folder, open Report Manager and click New Folder. The browser then displays a page similar to the Upload File page on which you can add the folder information with a description.

• You can use Report Manager to move content between folders after you have uploaded the content to the report server. To move content, you must first display the properties of the report in Report Manager and click Move. The browser then displays a page on which you can move the report.

• You can use Report Manager to enable the My Reports feature, which provides users with a location to store and customize their favorite reports without affecting other

Page 179: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-5

users. Administrators can enable this feature in the Site Settings area of Report Manager.

Note: You can also write scripts that deploy multiple reports, data sources, or resources by using the rs.exe utility.

Page 180: 2793A-ENU_TrainerWorkbook

6-6 Module 6: Publishing and Executing Reports

Updating Data Sources

During the lifecycle of your Microsoft SQL Server™ 2005 Reporting Services implementation, you will probably need to update data source properties. For example, if you move the reporting solution from a development environment to a production environment, you will need to change the data source’s server and database properties.

Key Points • You can use Report Manager to update both shared and report specific data sources

and overwrite properties stored in the report server database. However, these changes will not update the original .rds files (shared data source files) or .rdl files (data source files embedded in the report definition). Report Manager allows you to update the following properties: • Name

• Connection type

• Connection string

• Connection credentials

• You can use Report Designer to redeploy updated .rds files to the report server. The same data source properties can be updated as when you use Report Manager. When you republish a data source file, you can choose whether you want to overwrite the data source properties stored in the report server database. To overwrite the stored version, set the OverwriteDataSources option to True in the report project Property Pages dialog box.

Page 181: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-7

Updating Reports

Just as you need to update data sources during the lifecycle of your implementation, you also need to update the reports themselves. Updating a report requires you to change the .rdl file and then republish it.

Key Points • Updating or republishing a report:

• Replaces the report definition stored in the report server database

• Does not overwrite any parameter changes that have been made in Report Manager

• Does not update execution, history, security, or subscription properties. This consequence is advantageous, since you will most likely want to keep existing settings when simply updating the report’s definition.

• To update a report by using Report Manager, display the properties of the report and click Update. The browser then displays a page on which you can update the report with a newer version of the .rdl file.

• To update a report by using Report Designer, right-click the report item in Solution Explorer and click Deploy.

Page 182: 2793A-ENU_TrainerWorkbook

6-8 Module 6: Publishing and Executing Reports

Configuring Report Properties

You often need to make configuration changes to reports when you deploy them in order to control the report output. Configuration properties provide control over issues such as security, report delivery, and execution performance. Report Manager allows you to configure these properties.

Key Points • Data Sources. This property enables you to specify how a report’s queries connect to

their respective data sources. Depending on your execution scenario, you can specify that login credentials should be stored in the report server database or that the user must log on when viewing the report. You can also specify whether the report should use a shared data source or a data source that is specific to a particular report.

• Execution. This property enables you to specify the report execution frequency based on either a timeout value or a schedule. Choosing to cache a report in the report server database can improve performance for queries that take a long time to execute. You will learn more about execution and report caching later in this module.

• History. This property enables you to schedule report snapshots and add them to the report history. You can also set limits on the number of report snapshots that are stored in report history for future viewing.

• Parameters. This property enables you to control how users interact with each report parameter by enabling or disabling the parameter prompt and assigning a specific default value.

• Subscriptions. This property enables you to define how report users view reports. In a push delivery scenario, users and administrators can create subscriptions that automate report execution and route rendered reports by using e-mail or file shares.

Page 183: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-9

• Security. This property enables you to control end-user access to specific reports or folders and to control which data a user can view within a specific report.

Page 184: 2793A-ENU_TrainerWorkbook

6-10 Module 6: Publishing and Executing Reports

Lesson 2: Executing Reports

Objectives After completing this lesson, you will be able to:

• Describe the execution process flow. • Execute reports on demand. • Use session caching. • Use linked reports.

Page 185: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-11

Execution Process Flow

Execution is the process of turning a published report into a rendered report. Understanding this process is vital to ensuring that reports run efficiently even when your report system is under heavy load.

Key Points • At the time of report execution, a published report undergoes data retrieval and

processing. During this phase, the report server combines the layout definition with the report’s source data to produce an intermediate format of the report. To deliver the report to end users in a usable format, the Report Server sends the intermediate report to a rendering extension, which interprets it into a rendered report.

• You can optimize the execution process flow by specifying when the process steps should occur. In Report Manager, you can manipulate settings to specify whether steps occur at the time a user browses a report, or before user browsing. On-demand execution provides reports upon browsing, while cached instances and snapshot reports can be created ahead of time. The following topics examine these different options.

Page 186: 2793A-ENU_TrainerWorkbook

6-12 Module 6: Publishing and Executing Reports

Execute Reports on Demand

The default execution process for all reports is known as on-demand execution. This occurs when the user browses the report and provides the user with the most up-to-date data.

Key Points • The report server follows the same process for each user who opens a report that uses

on-demand execution. If ten users open the report, ten queries are issued to the source database. For an on-demand report, the user request triggers the following execution process: • The report server queries the source database to retrieve data and processes the

data according to the report definition.

• The report server creates an intermediate format of the report and stores a temporary copy in the session cache. The session cache is located in the ReportServerTempDB database

• The report server sends the intermediate report to a rendering extension with rendering format instructions and then forwards the rendered report to the requesting user.

• On-demand execution is the default report behavior. It often applies to the following execution scenarios: • Reports that have dynamic source data, such as an order status report that

requires up-to-the-minute data from the online transaction processing (OLTP) database. Note that you will need to assess the performance impact of this report on your OLTP database.

Page 187: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-13

• Infrequently accessed reports, such as an error-tracking report that is only executed once every couple of weeks. Pre-creating reports that are accessed infrequently wastes resources, since the reports must be stored in the report server database. In this scenario, it is more efficient to retrieve the data only when requested.

Page 188: 2793A-ENU_TrainerWorkbook

6-14 Module 6: Publishing and Executing Reports

Session Caching

Session caching improves report execution performance for individual users without requiring any special configuration settings. On-demand reports automatically take advantage of this execution feature. However, a user needs to manually refresh an on-demand report to see any data changes that have taken place during the time since the report was placed in the session cache.

Key Points • Sessions maintain the state between the client and server over HTTP. The user-

specific information relevant to a particular client session is known as the session state. Session management enables you to group together HTTP requests from the same session to form a conversation.

• When you browse a report, the report is added to the session cache that is stored in the ReportServerTempDB database. Each report has a default expiration time of ten minutes, after which the session is automatically terminated and the report removed from storage.

• While a report is stored in session state, the underlying report can change without affecting the report that is being viewed by the user. Report Manager provides a Refresh Report button so that users can manually refresh the report they are viewing to display any changes.

Page 189: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-15

Linked Reports

Linked reports are an easy and flexible way to customize report output for end users without the need to design new reports with Report Designer. Conceptually, it is similar to a program shortcut that you use to run a program or open a file.

Key Points • With linked reports, you can reuse a base report, including the data source and report

definition for other reports. For example, you could create multiple product category views of the Product Profitability report by creating one linked report for each product category. For each linked report, you assign a distinct default value for the category parameter.

• The main advantage that linked reports provide is the ability to alter a linked report properties without affecting the base report of any other linked reports. Report properties that you can modify include: • Execution

• Parameters

• Subscriptions

• Security

• To create a linked report using Report Manager, follow these procedures: 1. In Report Manager, open the existing report that you wish to use as the base

report.

2. Open the base report's General properties page.

3. Click Create Linked Report.

Page 190: 2793A-ENU_TrainerWorkbook

6-16 Module 6: Publishing and Executing Reports

4. Type a new report name and description. Optionally, you can change the new report's location by clicking Change Location and then clicking the new location.

5. Click OK to save the new report.

Page 191: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-17

Lesson 3: Creating Cached Instances

Objectives After completing this lesson, you will be able to:

• Execute cached instances. • Use query parameters with cached instances. • Use filters with cached instances. • Configure cached instances.

Page 192: 2793A-ENU_TrainerWorkbook

6-18 Module 6: Publishing and Executing Reports

Executing Cached Instances

To enhance the performance of report execution for multiple users, you can enable caching of a report and create a cached instance. This simple configuration change provides increased performance when compared to on-demand execution.

Key Points • Instance caching uses the following execution process:

1. When the first user requests a report, the report server retrieves the most up-to-date data and processes the report.

2. The report server creates an intermediate report and stores it in the cache in the ReportServerTempDB database. Unlike on-demand session caching, this report can stay in the cache for a specified number of minutes or until a particular scheduled time.

3. The report server flags the intermediate report as a cached instance.

4. The report server renders the report from the cached instance.

• Subsequent requests for the report from all users are processed by using the cached instance until the cached instance expires; this greatly increases the performance of the report.

Page 193: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-19

Using Query Parameters with Cached Instances

Cached instances require report storage in the report server cache. If a report uses query parameters, multiple instances of the report may need to be cached. However, this can still provide a performance improvement when compared to on-demand execution.

Key Points • A report’s query parameters are applied when a cached instance is created. Therefore,

the data stored in the cached instance is a restricted data set and only contains the data matching the supplied parameters.

• When a user specifies different parameter values for a report, a new cached instance is created if one does not already exist that exactly matches the newly supplied parameters. At any one time, a cached instance can exist for every combination of parameter values. For example, if you have a sales report with a sales office parameter, you can have a cached instance for each sales office. Use caution when creating cached instances involving query parameters, as this may result in a large number of instances being stored in the report server cache. An alternative to creating multiple cached instances is to filter a single cached instance as described in the following topic.

Page 194: 2793A-ENU_TrainerWorkbook

6-20 Module 6: Publishing and Executing Reports

Using Filters with Cached Instances

In order to avoid caching multiple copies of a report based on different query parameters, you can apply filters to a linked report. This option provides some of the performance benefits of caching and also reduces the number of cached instances.

Key Points • Unlike query parameters, filters are applied to the cached instance each time the

linked report is viewed. The report server uses the same cached instance of the report for each new request even if the parameters are different.

• Filters use the current report parameter values defined by the user. The filtered cached instance is not available to other users, so it is recreated dynamically for each user who requests it.

• When a user specifies different report parameter values, instead of creating a new cached instance, the existing cached instance is filtered. Because filters are applied after a cached instance is created and because the filtered instance is not available to other users, filters do not receive as many performance benefits from cached instances as query parameters. However, this technique can prevent the cache from becoming bloated with multiple versions of the same report.

Page 195: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-21

Configuring Cached Instances

In order to take advantage of instance caching, you must manually configure reports by using Report Manager. Otherwise, reports will be executed by using the on-demand technique by default.

Key Points • All cached instances are temporary and must expire at a certain time to allow the data

to refresh. You can control how the cache expires by choosing from the following list of options available in Report Manager: • At a defined interval. Allow a cached instance to expire after a specific number

of minutes from the time of its creation, for example, 30 minutes after creation.

• Report-specific schedule. Apply an expiration schedule that pertains to a particular report. For example, you can set up a schedule to clear a single report cache once every day of the week.

• Shared schedule. Apply a common expiration schedule to be used across multiple reports. For example, you can set up a shared schedule to clear multiple reports in the cache once per week.

• Forced expiration. Report Server may force expiration of cached instanced under certain conditions. These conditions include:

• Modification of the report definition

• Modification of the data source credentials

• Deletion of the report from the server

• Modification of execution options

Page 196: 2793A-ENU_TrainerWorkbook

6-22 Module 6: Publishing and Executing Reports

• You can have a cached instance for every combination of parameter values that are associated with query parameters. There is no hard-coded limit on the number of cached instances allowed.

• Expirations are implemented by using SQL Server Agent jobs. For this reason, you must ensure that SQL Server Agent is running.

• To create a cached instance, you must configure the data source settings to use login credentials stored in the report server database. Report Manager will display an error if you attempt to create a cached instance without this setting. You can choose to use Microsoft Windows® or SQL Server authentication.

Page 197: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-23

Lesson 4: Creating Snapshots and Report History

Objectives After completing this lesson, you will be able to:

• Execute snapshot reports. • Use query parameters with snapshots. • Use filters with snapshots. • Configure snapshots. • Use Report History. • Configure Report History.

Page 198: 2793A-ENU_TrainerWorkbook

6-24 Module 6: Publishing and Executing Reports

Executing Snapshot Reports

Snapshot reports pre-create reports to maximize performance of your reporting system. This is particularly useful for reports that take a long time to generate.

Key Points • Unlike on-demand reports, snapshots undergo data retrieval and processing before

report browsing. Snapshot reports execute the following process: 1. A scheduled event occurs.

2. The intermediate report is generated and the result is then stored as a snapshot in the report server database. Note that this is a different database location than for cached instances.

3. Report requests are satisfied by retrieving and rendering the stored snapshot.

• Snapshots reports often apply to the following execution scenarios: • You want to capture report data at a specific time. For example, the batch

window for executing the on-hand inventory report is between 3:00 A.M. and 4:00 A.M. each workday. In this scenario, you can schedule a snapshot to be created at 3:00 A.M..

• Multiple people need access to the same data. For example, to make sure that everyone has the same finance data, you set up the company’s financial statements as report snapshots that execute at specific intervals.

• You want to prevent arbitrary report execution. For example, when the customer invoice report queries the OLTP database during business hours, it slows down system performance. To prevent unnecessary data load on your OLTP database

Page 199: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-25

as well as inconsistent result sets, you execute the report as a snapshot every evening.

• You want to provide reports that use queries that take a long time to run. For example, you configure the lengthy year-to-date commission sales report to execute every week on Sunday evening so that it is available to users on Monday morning.

Page 200: 2793A-ENU_TrainerWorkbook

6-26 Module 6: Publishing and Executing Reports

Using Query Parameters with Snapshots

Cached instances of reports support the use of query parameters. However, snapshot reports cannot make use of query parameters because of the snapshot’s execution process.

Key Points • Query parameters are applied at the time a snapshot is created. This means that the

snapshot contains a restricted data set that does not change based on user input. • The query parameters used to create a snapshot are assigned the parameters’ default

values, which have been defined in Report Manager. If you want a snapshot for multiple values of a parameter, then you can use linked reports, each with a different default value.

• A user cannot change report parameter values when viewing a snapshot report, so only the restricted data set can be viewed. Using snapshots with query parameters freezes the data at a point in time. This behavior may or may not be appropriate for your situation, depending on what flexibility you want to grant to users. For example, if you want your company’s sales performance report to show data only for a specific month, specify default query parameters for the month and year and create a snapshot report. Each user will see the same view of the report until the snapshot is altered.

Page 201: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-27

Using Filters with Snapshots

Again, when you use snapshot reports, query parameters do not provide any flexibility because users cannot change the parameter values. However, users can apply filters to snapshots to achieve this extra level of functionality.

Key Points • The report server applies filters to a snapshot during browsing. The performance

improvements of snapshots still exist because data retrieval only occurs when producing the snapshot, not when applying the filter.

• Filters use the current report parameter values specified by the user so that the report only displays the information required by each user. You will often use filters with linked reports.

• Changing the report parameter values does not create a new snapshot. Instead, it filters the current snapshot. For example, you want your company’s sales performance report to execute for a specific month, but you also want users to be able to change which sales office they are viewing. In this scenario, you might use query parameters for month and year and apply a filter for sales office. The snapshot freezes the data for the particular month and year and filters the sales office dynamically for whatever value the end user specifies. Each user’s sales office view comes from the same snapshot; however, the snapshot is filtered by the sales office that they specified.

Page 202: 2793A-ENU_TrainerWorkbook

6-28 Module 6: Publishing and Executing Reports

Configuring Snapshots

As with instance caching, you must manually configure snapshot reports by using Report Manager. Otherwise, reports will use on-demand execution by default.

Key Points • All snapshots require explicit execution before they become visible to end users. You

can control this execution by choosing from the following list of options available in Report Manager: • Manually. Create a snapshot manually with the New Snapshot button when

viewing the history of a report. Use this option when you want to store a snapshot for future viewing even if new replacement snapshots are created.

Alternatively, you can create a snapshot without adding it to the report history by selecting the Create a report snapshot when you click the Apply button on this page check box on the Execution property page of a report.

• Report-specific schedule. Apply a schedule for a particular report. You configure this schedule on the Execution property page of the report.

• Shared schedule. Apply a common schedule that you can reuse across multiple reports. You configure this schedule by creating a shared schedule on the Shared Schedules page in Report Manager and linking to it on the Execution property page of the report. Note that the Shared Schedules page is accessible from the Site Settings page, which may not be available because of security settings.

• The report server will only allow one snapshot at a time for a particular report, and each new snapshot replaces the previous one unless specified otherwise.

Page 203: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-29

• Scheduled snapshots are implemented by using SQL Server Agent jobs. For this reason, you must ensure that SQL Server Agent is running.

• Like cached instances, snapshots require data source credentials to be stored in the report server database.

Page 204: 2793A-ENU_TrainerWorkbook

6-30 Module 6: Publishing and Executing Reports

Using Report History

By default, a new snapshot automatically replaces the previous snapshot, so the report server database only keeps one version. However, you may want to be able to retrieve older versions of a snapshot for various reasons. You can achieve this with report history.

Key Points • Report history is a collection of snapshots that have been stored in the report server

database for future reference. Report history enables you to keep a record of all snapshot reports that are generated. There are a variety of ways to create report history. One of the most common is to add a snapshot to report history on creation of the snapshot.

• End users or processes can specifically request a report history instance. In these situations, the report history requests are satisfied by using report history snapshots.

Page 205: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-31

Configuring Report History

Report history is not maintained by default for any report. You must manually configure this feature by using Report Manager. Report Manager provides various options when configuring report history.

Key Points • When you configure report history, you have the following options:

• Store all snapshots for a particular report in report history. In this scenario, whenever a snapshot is created, it is copied to report history automatically.

• Manually add snapshots on an as-needed basis. Here, only snapshots that you have chosen manually are added. This may be useful when a particular set of data will be of interest in the future, but you cannot predict exactly when that time will be; in other words, if it does not fit a defined schedule.

• Use a schedule to add snapshots to report history. If a report you schedule does not have a snapshot, then report history scheduling will first create a snapshot and then add it to report history. If the snapshot already exists, then report history scheduling will use the current snapshot and add it to report history. To implement the scheduled creation of report history, you use SQL Server Agent jobs.

• Limit the number of snapshots stored in report history. You can set a limit on snapshots for a specific report by using the History property page of a report. Alternatively, you can set a limit globally across all reports by using the Site Settings page in Report Manager.

Note that you can also keep an unlimited number of snapshots stored in report history—this is the default option.

Page 206: 2793A-ENU_TrainerWorkbook

6-32 Module 6: Publishing and Executing Reports

• Like snapshots and cached instances, producing report history requires a report to have stored credentials.

Page 207: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-33

Lab: Publishing and Executing Reports

After completing this lab, you will be able to:

• Publish and view reports. • Execute reports by using session caching, cached instances, and snapshots.

Estimated time to complete this lab: 45 minutes

Lab Setup For this lab, you will use the available virtual machine environment. Before you begin the lab, you must:

• Start the 2793A-MIA-SQL-06 virtual machine. • Log on to MIAMI by using the user name Student and the password Pa$$w0rd.

Lab Scenario The Adventure Works team has asked you to publish a number of pre-written reports to a report server. You must configure report delivery so that the performance of the report server is maintained while ensuring that each report is delivered in a timely fashion.

Page 208: 2793A-ENU_TrainerWorkbook

6-34 Module 6: Publishing and Executing Reports

Exercise 1: Publishing Reports In this exercise, you will publish Adventure Works reports. You will view the reports by using Report Manager and then modify one of the reports for redeployment. Finally, you will ensure that your redeployed report executes as expected.

Tasks Supporting information

1. Set up the lab environment. • Execute the runScripts.bat batch file in the D:\Labfiles\Starter\Exercise01 folder.

2. Open the Adventure Works solution.

• Using Business Intelligence Development Studio open the AdventureWorks.sln solution in the D:\Labfiles\Starter\Exercise01\AdventureWorks folder.

• Browse the three projects that make up the Adventure Works solution and note the following: • The Product Sales project has three reports that use two shared

data sources. • The Territory Sales project has three reports that use report-

specific data sources. • The Reseller Sales project has three reports that use report-

specific data sources.

3. Deploy the Adventure Works solution.

• Edit the properties of the Product Sales project. • Under Deployment, set the TargetServerURL to

http://miami/ReportServer. • Using Solution Explorer, deploy the AdventureWorks solution. • Examine the Output window to verify that the solution has been

successfully deployed.

4. Browse the published reports.

• Using Microsoft Internet Explorer®, browse to Report Manager at http://miami/reports.

• Browse the Product Profitability report located inside the Product Sales folder, then close Internet Explorer.

5. Update the Product Profitability report.

• Using Business Intelligence Development Studio, view the Product Profitability report in Layout view.

• Add a text box to the page footer with the following features. • Set the position to the right of the Company Confidential box. • Resize to fill the full width of the report. • Set the expression to: = Globals!ExecutionTime. • Set the formatting to Italic, Align Right.

• Preview the report to verify that the current data and time are shown in the page footer.

• Deploy the Product Profitability report. Examine the Output window. The build and deploy has have succeeded, but with warnings. The data source could not be deployed because it already exists. • Edit the properties of the Product Sales project.

• Under Deployment, change the OverwriteDataSources property to True.

• Redeploy the Product Productivity report and verify that there are

Page 209: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-35

Tasks Supporting information

no errors or warnings. • Close Business Intelligence Development Studio.

6. Browse the updated Product Profitability report.

• Use Report Manager to view the Product Profitability report. • Verify that the current data and time is shown on the page footer.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 210: 2793A-ENU_TrainerWorkbook

6-36 Module 6: Publishing and Executing Reports

Exercise 2: Executing Reports In this exercise, you will execute an on-demand report by supplying user credentials.

Tasks Supporting information

1. Configure the Order Details report for on-demand execution.

• Using Report Manager, browse the Order Details report in the Reseller Sales folder. • Notice that the report requires a start date, an end date, and a

reseller to execute. • On the Properties tab, edit the Data Sources properties.

• Configure the data source to use the credentials supplied by the user running the report as Windows credentials when connecting to the data source.

• Examine the Execution properties. • Notice that by default, reports are set to run on demand with the

most recent data.

2. View the Order Details report.

• View the report. • Click the View tab. • Use MIAMI\Student as the user name. • Use Pa$$w0rd as the password.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 211: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-37

Exercise 3: Configuring and Viewing a Cached Report In this exercise, you will configure a report to be cached.

Tasks Supporting information

1. Configure the Product Sales YTD report for cached execution.

• Using Report Manager, view the details of the reports in the Product Sales folder.

• Edit the Execution properties of the Product Sales YTD report. • Set the report to Cache a temporary copy of the report.

Expire copy of report after a number of minutes. Leave the default value of 30.

• Notice the error message that appears, informing you that the credentials that are used to run this report are not stored. Because of this, the cache configuration has failed.

• Examine the Data Sources properties of the Product Sales YTD report. • Notice that /Product Sales/AdventureWorksDW is the data

source used by this report. You cannot update the login credentials here because this data source is shared.

• Edit the AdventureWorksDW data source in the Product Sales folder. • Use credentials that are stored securely in the report server. • Use the Windows account MIAMI\Student with the password

Pa$$w0rd. • Enable the report for instance caching.

• View the details of the Product Sales YTD report in the Product Sales folder.

• Edit the Execution properties of the Product Sales YTD report and set the report to select Cache a temporary copy of the report. Expire copy of report after a number of minutes. Leave the default value of 30.

• View the report. • By viewing, you have just created a cached instance that will

expire in 30 minutes.

2. Expire copies of the Product Sales YTD report on a schedule.

• Edit the Execution properties of the Product Sales YTD report. • Select the Cache a temporary copy of the report. Expire

copy of report on the following schedule option. • Configure the Report-specific schedule. • In Daily Schedule, set the On the following days to execute

on every day of the week. • Set the Start time to 11PM.

• View the Product Sales YTD report. • By viewing, you have just created a cached instance that will

expire at 11:00 P.M. this evening.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 212: 2793A-ENU_TrainerWorkbook

6-38 Module 6: Publishing and Executing Reports

Exercise 4: Configuring and Viewing a Snapshot Report In this exercise, you will configure a report to be rendered from a snapshot. You will also configure the report to store its snapshot history.

Tasks Supporting information

1. Change the Reseller Sales report to use AdventureWorksDW.

• Using Report Manager, edit the Data Sources properties of the Reseller Sales report in the Reseller Sales folder. • Note that to create a snapshot for this report, you must store its

data source login credentials. • Use the /Product Sales/AdventureWorksDW shared data

source.

2. Schedule a snapshot to run at the beginning of the month.

• On the upper right-hand side of the screen, click Site Settings. • At the bottom on the screen, click Manage shared schedules. • Create a new schedule.

• Name the schedule Beginning of Month. • Configure as a monthly schedule, occurring on the first day of

the month. • Configure the schedule to start at 05:00 AM.

• Edit the Execution properties of the Reseller Sales report in the Reseller Sales folder. • Configure the report to use the Beginning of Month shared

schedule. • Do not create a snapshot of the report when you click Apply.

• Note that the report will not be available until it executes for the first time on the first day of next month.

3. Store Reseller Sales snapshots in report history.

• Edit the History properties of the Reseller Sales report in the Reseller Sales folder. • Select the Store all report execution snapshots in history

check box. • Select the Limit the copies of report history option, and then

type 12 in the text box.

4. View the Reseller Sales report and report history.

• View the Reseller Sales report. • The following error message is displayed:

The selected report is not ready for viewing. The report is still being rendered or a report snapshot is not available. (rsReportNotReady).

• Edit the Execution properties. • Click the Create a report snapshot when you click the Apply

button on this page check box. • Apply the changes to create a report snapshot.

• View the Reseller Sales report. • You are viewing the report snapshot.

• Click the History tab. • Notice there is a snapshot that has been created and is now

stored in history.

Page 213: 2793A-ENU_TrainerWorkbook

Module 6: Publishing and Executing Reports 6-39

Note: The answers to the practices and labs are on the Student Materials CD.

Lab Shutdown After you complete the lab, you must shut down the 2793A-MIA-SQL-06 virtual machine and discard any changes.

Important: If the Close dialog box appears, ensure that Turn off and delete changes is selected, and then click OK.

Page 214: 2793A-ENU_TrainerWorkbook
Page 215: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports

Table of Contents Module Overview 7-1

Lesson 1: Introduction to Report Subscriptions 7-2 Lesson 2: Creating Report Subscriptions 7-5 Lesson 3: Managing Report Subscriptions 7-11 Lab: Implementing Subscriptions 7-17

Page 216: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 217: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports 7-1

Module Overview

Objectives After completing this module, you will be able to:

• Describe report subscriptions. • Create report subscriptions. • Manage report subscriptions.

Page 218: 2793A-ENU_TrainerWorkbook

7-2 Module 7: Using Subscriptions to Distribute Reports

Lesson 1: Introduction to Report Subscriptions

Objectives After completing this lesson, you will be able to:

• Describe subscriptions. • Describe appropriate scenarios for report subscriptions.

Page 219: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports 7-3

What Are Subscriptions?

Some users will be satisfied by manually viewing reports only when they feel they need to. Other users may prefer or require automated notification about when they should view a report. Subscriptions automatically provide reports to users.

Key Points • Subscriptions execute and deliver rendered reports to users at regular or irregular

intervals. There are two types of subscriptions: standard and data-driven. Users typically create standard subscriptions, while administrators typically create data-driven subscriptions. You will learn more about these two types of subscriptions in the following topics.

• Reporting Services supplies a set of delivery extensions, including: • E-mail delivery. Enables you to send rendered reports, report hyperlinks, or

notifications to users through automated e-mail. This form of delivery requires the e-mail server to be a remote or local Simple Mail Transfer Protocol (SMTP) server that is located on the same network as the report server.

• File delivery. Enables you to deliver rendered reports to network file shares.

• Custom delivery. You can add to this list of delivery options by creating your own custom delivery extensions.

Page 220: 2793A-ENU_TrainerWorkbook

7-4 Module 7: Using Subscriptions to Distribute Reports

Subscription Scenarios

Subscriptions are a good way to distribute reports in many different scenarios.

Key Points Common scenarios for subscriptions include:

• Delivering reports by using e-mail to single users or lists of users. • Creating reports in PDF, Web archive, or Microsoft® Excel® format for offline

report viewing. • Archiving reports to a network file share that could be backed up by using normal

backup procedures. • Sending large reports to disk that would take too long to display in a browser. • Pre-loading the cache to reduce waiting time for users. • Targeting a desktop application as a viewing device by exporting the report in a

specific format, such as Excel. • Customizing report output format, delivery options, and report parameter settings for

individual users with a data-driven subscription.

Page 221: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports 7-5

Lesson 2: Creating Report Subscriptions

Objectives After completing this lesson, you will be able to:

• Describe standard subscriptions. • Create standard subscriptions. • Describe data-driven subscriptions. • Create data-driven subscriptions.

Page 222: 2793A-ENU_TrainerWorkbook

7-6 Module 7: Using Subscriptions to Distribute Reports

What Are Standard Subscriptions?

Individual users typically create and manage standard subscriptions. A standard subscription consists of static values that cannot be varied during subscription processing. For each standard subscription, there is exactly one set of report presentation options, delivery options, and report parameters.

Key Points • A standard subscription delivers one rendered report to one destination, such as an e-

mail address (or addresses) or a single file share. • Both users and administrators can define standard subscriptions by using Report

Manager to specify the required delivery method and delivery options.

Page 223: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports 7-7

Creating Standard Subscriptions

Standard subscriptions are simple to create and do not require any level of expertise in how reports are created. The main required action is to set the various configuration options by using Report Manager.

Key Points • To set up a standard subscription, you must specify the following configuration

options in Report Manager: • Delivery method. Specifies e-mail or file-share delivery.

• Delivery information. For e-mail delivery, this includes the e-mail address or addresses, subject line, and so on. For file-share delivery, this includes the share location and file name.

• Render format. This is the output format of the report. Options include Excel, TIFF, Extensible Markup Language (XML), and more. For e-mail delivery, you can specify whether to include a hyperlink in addition to or in place of the rendered report. You can also choose not to render the report or link in an e-mail message, but simply provide notification that the report is available.

• Processing conditions. This is the processing schedule of the subscription. For a subscription based on a snapshot, you can execute the subscription upon update of the snapshot. For non-snapshot reports, you can create a schedule or use a shared schedule.

• Parameters. These are the parameter values that the report will use when it is rendered.

Page 224: 2793A-ENU_TrainerWorkbook

7-8 Module 7: Using Subscriptions to Distribute Reports

What Are Data-Driven Subscriptions?

Data-driven subscriptions provide greater flexibility than standard subscriptions because you can configure settings for each user individually.

Key Points • A data-driven subscription delivers a report in many rendered formats to many

destinations. For example, you can use a data-driven subscription to e-mail a sales performance report to a list of users in a custom format for each user.

• To make a data-driven subscription dynamic, the report server uses delivery settings stored in a database table. This stored information can include the following: • Dynamic list of destinations. Specify destinations, such as e-mail recipients or

file share folders.

• Report rendering format. Assign a different rendering format for each destination.

• Parameter values. Assign a different parameter value for each destination.

Page 225: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports 7-9

Creating Data-Driven Subscriptions

Only administrators normally create this type of subscription because of the complexity of the creation process, which involves direct access to database tables.

Key Points • Use the following procedure to create a data-driven subscription:

1. Using Microsoft SQL Server™ Management Studio, create a subscriber table in a database and populate it with subscriber information.

2. Using Report Manager, ensure that connection credentials are stored with the report on the report server.

3. Create a new data-driven subscription and choose your delivery method.

4. Configure a connection to the database that contains the subscriber table.

5. Create a query to retrieve the subscriber information from the subscriber table.

6. Set the subscription properties by using the same options as for a standard subscription.

Page 226: 2793A-ENU_TrainerWorkbook

7-10 Module 7: Using Subscriptions to Distribute Reports

Lesson 3: Managing Report Subscriptions

Objectives After completing this lesson, you will be able to:

• Manage subscriptions with Report Manager. • Manage subscription and delivery availability. • Control report distribution. • Monitor subscription status.

Page 227: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports 7-11

Managing Subscriptions with Report Manager

A user who creates a subscription owns that subscription. Each user can modify or delete the subscriptions that he or she owns. To create a subscription, you must have access to the report itself and your security role assignment must support the ability to manage individual subscriptions.

Key Points • The Subscriptions page allows you to create, edit, and modify a subscription for a

specific report. • To create a subscription, follow these steps:

i. View the report by using Report Manager.

ii. Navigate to the Subscriptions page.

iii. Click either New Subscription or New Data-driven Subscription.

iv. Complete the appropriate subscription information, and then click OK

• To edit a subscription, click the Edit link and make changes as appropriate.

• To delete a subscription, select the subscription by using the provided check box, and then click Delete.

• The My Subscriptions page allows you to edit and delete existing subscriptions that you own using the same process as described above. You cannot create subscriptions by using this page.

Page 228: 2793A-ENU_TrainerWorkbook

7-12 Module 7: Using Subscriptions to Distribute Reports

Managing Subscription and Delivery Availability

Administrators might want to remove users’ ability to create subscriptions. They may also want to remove certain delivery extensions from a Report Server installation, such as e-mail or file-share delivery.

Key Points • Security roles help to keep the Reporting Services system controllable for

administration staff. Most users belong to the Browser role by default, which includes the ability to manage individual subscriptions. To disable the ability to manage subscriptions for this role, edit the role by navigating to the Site Settings page, using the Configure item-level role definitions link, and then clearing the check box for the Manage individual subscriptions option.

• The RSReportServer configuration file maintains the installed delivery extensions. To remove a delivery extension, edit the configuration file and locate the Delivery element within the Extensions element, then remove the extension you wish to disable.

Page 229: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports 7-13

Controlling Report Distribution

Controlling report distribution is an essential part of managing a reporting server. It is important to use security settings and control of distribution to ensure that users only receive appropriate reports that they are entitled to view.

Key Points • Securing a report against unauthorized access must be the top priority for controlling

report distribution, because users who can view a report can possibly distribute it. You will learn about securing reports in Module 8, "Administering Reporting Services," in Course 2793, Implementing and Maintaining Microsoft SQL Server 2005 Reporting Services.

• Consider the following options for controlling e-mail distribution: • You can configure a report server to limit e-mail distribution to a list of specific

host domains by modifying the RSReportServer configuration file.

• You can change configuration settings to hide the To field in a subscription, so that reports are delivered only to the user defining the subscription. However, this does not stop the user from forwarding the e-mail message after receiving it.

• Sending the report server URL (as opposed to sending the rendered report) is the most effective way to control report distribution. Microsoft Windows® authentication and a role-based authorization control access to a report, so that if a user accidentally receives the URL of a report that he or she is not authorized to view, the report server will not display the report.

• To control file-share delivery, use Access Control Lists (ACLs) to secure access to the shared folders where reports are stored. This approach relies on the operating system instead of the report server to validate users who want to view a report.

Page 230: 2793A-ENU_TrainerWorkbook

7-14 Module 7: Using Subscriptions to Distribute Reports

Monitoring Subscription Status

Individual users can monitor the status of a subscription by using the My Subscriptions page or a Subscriptions tab in Report Manager. These pages include columns that indicate the last time that the subscription was run and the status of the subscription.

Key Points • The following table shows the values that the status column can display. Status Description

New subscription Appears when you first create the subscription.

Inactive Appears when a subscription cannot be processed because it is inactive. An inactive subscription means that the delivery extension has been disabled, credentials are no longer stored with the report, parameter names or types have changed, or the report execution mode has changed.

Done: n processed of n1 total; n2 errors Shows the status of a data-driven subscription execution. n shows how many notifications have been processes at this time, n1 shows the total number of expected notifications, and n2 shows the current number of errors.

Failure sending mail The report server did not connect to the mail server.

File x was written to y The delivery to the file share location was successful.

An unknown error occurred when writing file

The delivery to the file share location did not succeed.

Failure connecting to the destination folder

The specified folder could not be found.

The file x could not be written to y The file could not be updated with a newer version.

Failure writing file x The delivery to the file share location did not succeed.

Page 231: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports 7-15

Lab: Implementing Subscriptions

After completing this lab, you will be able to:

• Create a standard subscription. • Create a data-driven subscription.

Estimated time to complete this lab: 30 minutes.

Lab Setup For this lab, you will use the available virtual machine environment. Before you begin the lab, you must:

• Start the 2793A-MIA-SQL-07 virtual machine. • Log on to MIAMI by using the user name Student and the password Pa$$w0rd.

Lab Scenario The Adventure Works team has asked you to publish a number of pre-written reports to a report server. You must configure the server so that the Sales team can retrieve sales figures in Excel format from a file share, and the regional directors receive relevant regional sales figures by e-mail, in a variety of formats.

Page 232: 2793A-ENU_TrainerWorkbook

7-16 Module 7: Using Subscriptions to Distribute Reports

Exercise 1: Creating a Standard Subscription In this exercise, you will create a standard subscription for the Product Profitability report. You will create a standard subscription that will deliver the report in Excel format to a specific file share.

Tasks Supporting information

1. Set up the lab environment. • Run the runScripts.bat batch file in the D:\Labfiles\Starter\Exercise01 folder.

2. Open and deploy the AdventureWorks solution.

• Using Business Intelligence Development Studio, open the AdventureWorks.sln solution in the D:\Labfiles\Starter\Exercise01\AdventureWorks folder.

• Deploy the AdventureWorks solution.

3. Configure a shared data source.

• Using Microsoft Internet Explorer®, browse to Report Manager at http://miami/reports.

• Edit the AdventureWorksDW data source located inside the Product Sales folder. • Use credentials that are stored securely in the report server. • Use the Windows account MIAMI\Student with the password

Pa$$w0rd. • Ensure that you do not select impersonation.

4. Create a standard subscription.

• Using Report Manager, view the Product Profitability report in the Product Sales folder.

• Create a new subscription. • On the Subscriptions tab, click New Subscription. • Set Delivered by to Report Server File Share. • Set the Path to MIAMI\Reports. • Set the Render Format to Excel. • Under Overwrite options, select the Increment file names as

newer versions are added option. • In the Subscription Processing Options, under Run the

subscription, ensure the When the scheduled report run is complete option is selected.

• Select Select Schedule, select the Once option, and then set the Start time to three minutes later than the current time.

• Under Report Parameter Values, select the default option for the Year and Month parameters.

• Set Category to All Product. • Under Credentials used to access the file share, set the User

Name to MIAMI\Student. • Set Password to Pa$$w0rd.

5. View the standard subscription output.

• Using Windows Explorer, in the Address bar, browse to \\MIAMI\Reports.

• Using Excel, examine Product Profitability.xls.

Page 233: 2793A-ENU_TrainerWorkbook

Module 7: Using Subscriptions to Distribute Reports 7-17

Exercise 2: Creating a Data-Driven Subscription In this exercise, you will create a data-driven subscription to deliver the Actual Vs Quota report to the company’s sales directors.

Tasks Supporting information

1. Change the Actual Vs Quota report to use a shared data source.

• Using Internet Explorer, browse to Report Manager at http://miami/reports.

• Browse the Actual Vs Quota report inside the Territory Sales folder. Note the following: • The report requires two parameters to execute: CalendarYear

and Group. When you build the subscription, it is important that the correct Group parameter value is linked to the corresponding regional Sales Director. This information is stored in a database table for each sales director, along with other report delivery information.

• Edit the Data Sources properties. • Click the A shared data source option, and then click Browse. • Expand the Product Sales folder, and then click

AdventureWorksDW.

2. View the SubscriptionGroupDirector table.

• Using SQL Server Management Studio, open the dbo.SubscriptionGroupDirector table in the AdventureWorksDW database on MIAMI.

• Notice that three directors are listed together with a number of report parameters.

3. Create a data-driven subscription.

• Using Report Manager, create a new data-driven subscription for the Actual Vs Quota report in the Territory Sales folder.

• Configure the subscription to notify recipients by e-mail. • Use the AdventureWorksDW shared data source. • Use the following query to retrieve delivery settings:

SELECT * FROM dbo.SubscriptionGroupDirector

• Specify the following delivery extension settings: • To: select Get the value from the database, set the Value to

To. • Leave Cc and Bcc set to their default values. • Reply-To: select Specify a static value, set the Value to

[email protected]. • Include Report: select Get the value from the database, set

the Value to IncludeReport. • Render Format: select Get the value from the database, set

the Value to RenderFormat. • Priority: select Specify a static value, set the Value to

Normal. • Subject: select Specify a static value, set the Value to

@ReportName was executed at @ExecutionTime. • Leave Comment set to default values. • Include Link: select Get the value from the database, set the

Value to IncludeLink. • Use the default value for the CalendarYear parameter.

Page 234: 2793A-ENU_TrainerWorkbook

7-18 Module 7: Using Subscriptions to Distribute Reports

Tasks Supporting information

• For the Group parameter, use the GroupParameter value from the database.

• Create a schedule for the subscription to run once, two minutes later than the current time.

4. View the subscription notifications.

• Use Microsoft Outlook® Express. • On the Tools menu, click Options. Then on the Read tab, clear the

Read all messages in plain text checkbox, and then click OK. • Examine the e-mail messages sent by the subscription, and view any

attachments.

Note: The answers to the practices and labs are on the Student Materials CD.

Lab Shutdown After you complete the lab, you must shut down the 2793A-MIA-SQL-07 virtual machine and discard any changes.

Important: If the Close dialog box appears, ensure that Turn off and delete changes is selected, and then click OK.

Page 235: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services

Table of Contents Module Overview 8-1

Lesson 1: Server Administration 8-2 Lesson 2: Performance and Reliability Monitoring 8-9 Lesson 3: Administering Report Server

Databases 8-19 Lesson 4: Security Administration 8-23 Lab: Administering Reporting Services 8-35

Page 236: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 237: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-1

Module Overview

Objectives After completing this module, you will be able to:

• Administer the reporting server. • Monitor performance and reliability. • Administer the Report Server databases. • Administer security.

Page 238: 2793A-ENU_TrainerWorkbook

8-2 Module 8: Administering Reporting Services

Lesson 1: Server Administration

Objectives After completing this lesson, you will be able to:

• Describe the Reporting Services configuration files. • Use Configuration Manager to modify the configuration files. • Assign service accounts to Reporting Services components.

Page 239: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-3

Reporting Services Configuration Files

A Reporting Services installation includes several Extensible Markup Language (XML) configuration files that control the behavior of various Reporting Services components. After installation, you may need to modify these configuration files to add or remove particular features, using the configuration tool or any XML editor.

Key Points • RSReportServer.config is located in the Microsoft SQL Server\

<SQL Server Instance>\Reporting Services\ReportServer folder, and it contains configuration settings for the Report Server. You can configure the options for this file as shown in the following table.

Setting Description

Database connection strings (various settings)

Configure the connection to the report server database. These settings are encrypted to provide greater security. You must use the rsconfig.exe utility to edit these values or use the Reporting Services Configuration Manager.

RSEmailDPConfiguration Configures the e-mail settings for delivery of reports using SMTP. Allows you to modify the server name, server port number, and connection timeout, among other settings.

Render Configures the rendering options for reports. These settings should match the Render settings in RSReportDesigner.config.

Data Configures the connection types available for data sources that provide the data for reports. These settings should match the Data settings in RSReportDesigner.config.

• RSWebApplication.config is located in the Microsoft SQL Server\ <SQL Server Instance>\Reporting Services\ReportManager folder, and it contains settings for Report Manager. You can configure the options for this file as shown in the following table.

Page 240: 2793A-ENU_TrainerWorkbook

8-4 Module 8: Administering Reporting Services

Setting Description

DeliveryUI Configures the available delivery extensions, which include e-mail or file share delivery. You can set a default delivery extension as well as configure the default rendered report type for each delivery mechanism.

MaxActiveReqForOneUser Configures the maximum number of active requests that a single user can have. The default value is 20 requests; any additional requests from a user are denied. To remove limits on the number of connections, set the value to 0.

• The ReportingServicesService.exe.config configuration file is located in Microsoft SQL Server\<SQL Server Instance>\Reporting Services\ReportServer\bin, and it contains information regarding the level of server tracing enabled on the report server. Tracing configuration is described in more detail in the next lesson.

• RSReportDesigner.config is located in the \Program Files\Visual Studio 8\Common7\IDE\PrivateAssemblies folder, and it contains settings for Report Designer. You can configure the options for this file as shown in the following table.

Setting Description

Render Configures the possible rendering options for previewing reports with Report Designer. The installed options include XML, comma separated values (CSV), Microsoft® Office Excel®, Portable Document Fomat (PDF), and so on.

Data Configures the connection types available for data sources that provide the data for reports. The installed options include SQL, OLEDB, open database connectivity (ODBC), and Oracle

Designer Configures the available query designers for use in Report Designer. A designer normally relates to a particular data source, but all of the provided data sources use a single designer extension.

You can create or add extension classes for all three elements by adding them to the appropriate element within the configuration file.

Page 241: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-5

Reporting Services Configuration Manager

The Reporting Services Configuration Manager provides a graphical user interface to modify several configuration settings stored in the previously described configuration files. These settings are grouped into the following core areas.

Key Points • Server status. Provides information about the status of the Report Server Microsoft

Windows® service (running or not), and provides buttons to start and stop the service. • Virtual directories. Enables configuration of the Report Server Web service and the

Report Manager Web site virtual directories. This allows you to change the virtual directory names after installation, as well as requiring Secure Sockets Layer (SSL) connections for the Web service if necessary.

• Service accounts. Enables configuration of the three Windows accounts that Reporting Services uses. The account options are: • Execution account. Configures an account to use for unattended processing at a

very low level.

• Windows Service Identity. The account used by the Report Server Windows service.

• Web Service Identity. The account used by the Report Server Web service and Report Manager.

The following topic describes these options in more detail.

• Report Server database setup. Creates and configures the report server databases that provide internal storage for one or more report server instances.

Page 242: 2793A-ENU_TrainerWorkbook

8-6 Module 8: Administering Reporting Services

• Encryption keys and initialization. Manages the symmetric key that is used to encrypt and decrypt data in a report server. This includes creating backups of encryption keys so that you can change service accounts, migrating to a different server, or initializing a new report server instance to share the report server database.

• E-mail delivery. Configures the Simple Mail Transport Protocol (SMTP) settings that enable the Report Server e-mail delivery extension.

Note: You can also use the RSConfig command prompt utility to modify many of these settings. This utility can be useful for creating reusable scripts.

Page 243: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-7

Assigning Service Accounts

Some Reporting Services components require specific user credentials in order to function. You will need to modify these settings after installation if you plan to change the user accounts used by Reporting Services.

Key Points • The Report Server Windows service can run as any of the following account options:

• Network Service account. This option is only available in Microsoft Windows Server® 2003 or later and is the recommended option.

• Domain user account. Ensure that the domain account can make network connections.

• Local System account. This option includes more permissions than are necessary and is therefore not recommended.

• Local Service account. This option will not work in most scenarios. Avoid using this built-in account unless all client and server operations are performed exclusively on the local computer.

You can also set this account using the Windows Services tool as you would for any other Windows service.

• Report Server Web Service account options include: • For Microsoft Internet Information Services (IIS) 5.0, the ASPNET account is

used for all ASP.NET Web sites by default and is not configurable using the administrative tool.

Page 244: 2793A-ENU_TrainerWorkbook

8-8 Module 8: Administering Reporting Services

• For IIS 6.0, application pools allow you to configure a different account for each application pool. Reporting Services can use one pool that is shared between both the Web service and Report Manager, or you can use separate pools.

• The account used by the report server must have database owner (dbo) privileges in the report server database. You configure this account during the Reporting Services installation. You can choose to connect to the database using either Microsoft Windows or SQL Server authentication. The configuration information for this account is encrypted in the configuration file for security reasons. If you need to edit the settings after installation, use the rsconfig.exe command-line utility or the Reporting Services Configuration Manager.

• The unattended execution account is used under special circumstances when other sources of credentials are not available. This occurs when the report server connects to a data source that does not require credentials or when it connects to another server to retrieve external image files or other resources that are referenced in a report. You can use either a Windows domain account or a local account for this optional setting.

Page 245: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-9

Lesson 2: Performance and Reliability Monitoring

Objectives After completing this lesson, you will be able to:

• Use trace files. • Log report exceptions. • Use performance counters. • Apply timeouts. • Suspend jobs.

Page 246: 2793A-ENU_TrainerWorkbook

8-10 Module 8: Administering Reporting Services

Using Trace Files

Reporting Services provides trace files with which you can monitor the status of the report server. Becoming familiar with these trace files will help you assess reasons for reporting problems if they should occur.

Key Points • Trace logs contain information about various report server operations, including the

following: • System information

• Events logged in the Application log

• Exceptions and warnings generated by the report server

• Inbound and outbound SOAP envelopes

• HTTP header, stack trace, and debug trace information

You can review trace logs to confirm report delivery, monitor report execution activity, and view error information.

• There are four trace files that located in the \Microsoft SQL Server\ <SQL Server Instance>\Reporting Services\LogFiles folder: • ReportServerService__<timestamp>.log. This is a trace log for the report

server Windows service worker threads.

• ReportServerService_main_<timestamp>.log. This is a trace log for the Report Server Windows service management threads.

• ReportServerWebApp__<timestamp>.log. This is a trace log for Report Manager.

Page 247: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-11

• ReportServer__<timestamp>.log. This is a trace log for the Report Server Web service.

• Trace files use the report server's local system time to generate a new log each day or generate a new log when the Reporting Services application restarts. Because trace logs are not automatically removed from the server, you should implement a strategy for archiving and removing old log files if you decide to keep tracing enabled.

• You can control the level of information recorded in the trace logs by altering the DefaultTraceSwitch configuration settings in the ReportingServicesService.config or the two Web.config files (located in \Reporting Services\ReportManager and \Reporting Services\ReportServer). You can edit this setting using any XML editor. You can set DefaultTraceSwitch to one of the following values: • 0 = Disables tracing

• 1 = Exceptions and restarts

• 2 = Exceptions, restarts, warnings

• 3 = Exceptions, restarts, warnings, status messages. (This is the default setting.)

• 4 = Verbose mode

The following XML code example shows how to set the DefaultTraceSwitch value in the ReportingServices.config file.

<system.diagnostics> <switches> <add name="DefaultTraceSwitch" value="3" /> </switches> </system.diagnostics>

It is recommended that you do not disable tracing completely, so that you can at least log exception information.

Page 248: 2793A-ENU_TrainerWorkbook

8-12 Module 8: Administering Reporting Services

Logging Report Execution

One of the most important aspects of Reporting Services administration is logging report execution. This type of log information offers troubleshooting and monitoring benefits particularly related to report execution.

Key Points • Report execution information is logged directly in the report server database. The log

information allows you to view the frequency of particular report requests, as well as which users make them.

• For each report execution, there is a variety of information captured, including: • Data retrieval time. Time (in milliseconds) spent executing the query

• Processing time. Time (in milliseconds) spent processing the report, including applying filters, subtotals, grouping, sorting, and so on

• Rendering time. Time (in milliseconds) spent rendering the report in a specific format

• Source. Origin of the report execution. Possible values include:

• Live

• Cache

• Snapshot

• History

• Use Report Manager to set up execution logging by specifying the following options:

Page 249: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-13

• Enable or disable report execution logging. Logging is enabled by default in Report Manager. You can disable it by opening Site Settings and clearing the Enable report execution logging check box.

• Specify removal of log entries. Log entries are removed after a specified number of days. The default is 60 days.

• Reporting Services stores the log data in the ExecutionLog table in the report server database. The table’s data is not easy to understand as it is, so Reporting Services provides a sample Microsoft SQL Server™ Information Services package named RSExecutionLog_Update.dtsx for exporting logged records to another location for viewing and analysis. You can also use the sample to export records from the execution log on a periodic basis by creating a schedule.

Page 250: 2793A-ENU_TrainerWorkbook

8-14 Module 8: Administering Reporting Services

Using Performance Counters

When reports are executed, statistical information is created in the form of performance counters. This information is viewable through the Performance tool, Performance Logs and Alerts, and Task Manager.

Key Points • The Reporting Services Web Service performance object includes 18 performance

counters that relate to the performance of the report server. These counters are categorized as counters that show current activity or counters that show a total number, counting everything since the Web service was last started. Deciding which counters you should use will depend on your specific needs. Performance counters include: • Active Sessions. A count of all active browser sessions.

• Reports Executed/Sec. The number of successful report executions per second. Use this counter with Request/Sec to compare execution to report requests that can be returned from the cache.

• Total Cache Hits. The total number of requests for reports from the cache since the service was last started.

• Total Requests. The total number of requests made to the report server since the service was last started.

• The Reporting Services Windows Service performance object includes 23 performance counters that relate to the performance of scheduling and delivery. This includes subscription and delivery, report execution snapshots, and report history

Page 251: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-15

statistics. These counters are categorized in the same way as the Web service performance counters. Performance counters include: • Deliveries/Sec. The number of report deliveries per second, from any delivery

extension.

• Total Processing Failures. The total number of report processing failures since the service was last started. This counter is reset when the application domain recycles—this is an automated way to restart the application.

Page 252: 2793A-ENU_TrainerWorkbook

8-16 Module 8: Administering Reporting Services

Applying Timeouts

Occasionally, a report may take a long time to execute. If reports take too long to execute, users can become impatient, which can often lead them to trying to run the report again, before the original request has been satisfied. This in turn can slow down the system further. You can configure timeouts in order to prevent such problems from occurring.

Key Points • Source query timeouts help you prevent unpredictable source queries from running

for an unreasonable length of time. You can also use these timeouts to protect reports from any delays that result from unanticipated changes in the source database that inadvertently impact query performance. You can specify the maximum time limit for individual data set queries during report design by using the Dataset dialog box in Report Designer. When the timeout is exceeded, the execution fails automatically and the user receives an error message in the browser window.

• Report execution timeouts help you prevent any long-running report executions that go beyond the acceptable threshold. You can specify the maximum time limit for overall report execution in Site Settings in Report Manager. Alternatively, you can configure a timeout for each report individually in the report execution properties. When the timeout is exceeded, the user receives an error message in the browser window.

Tip: You can also cancel long-running queries or subscriptions manually by using the Manage Jobs page in Report Manager

Page 253: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-17

Suspending Jobs

During the life cycle of your Reporting Services implementation, you may need to pause or temporarily suspend the execution of a job, such as a subscription or snapshot execution. Reasons for suspending jobs may include the need to take into account holidays, maintenance, or troubleshooting incorrect data.

Tip: The options below are only available for shared data sources, not custom sources. For this reason, as well as the ease of maintenance associated with shared data sources, it is a good practice to use shared data sources whenever possible.

Key Points • Disabling a shared data source disables the following functions:

• Report execution. Users can still view reports based on existing snapshots or cached versions, but no new execution can occur. Report Manager displays an error message if users attempt to execute reports.

• Data-driven subscription processing. No data-driven subscriptions based on the shared data source can run; however, standard subscriptions can still run.

You enable and disable shared data sources in the General properties of Report Manager for the individual shared data source.

• Pausing a shared schedule disables the following functions: • Scheduled report execution. Snapshot reports maintain their existing data, but

no new scheduled execution takes place.

• Subscription processing. No deliveries occur that rely on the shared schedule.

Page 254: 2793A-ENU_TrainerWorkbook

8-18 Module 8: Administering Reporting Services

• Scheduled cache expiration. Scheduled removal of reports from the cache does not occur. This does not affect removal based on a timeout value.

You pause and resume shared schedules in the Shared Schedules section of Report Manager.

Page 255: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-19

Lesson 3: Administering Report Server Databases

Objectives After completing this lesson, you will be able to:

• Describe Reporting Services database storage. • Determine disk space requirements. • Define a backup and restore strategy.

Page 256: 2793A-ENU_TrainerWorkbook

8-20 Module 8: Administering Reporting Services

Reporting Services Database Storage

Reporting Services requires two SQL Server databases in order to operate: the ReportServer database and the ReportServerTempDB database. Both databases are created automatically during installation. Understanding what information is stored in each database will help you manage the physical files that make up the databases.

Key Points • The following items are stored in the ReportServer database:

• Reports, folders, shared data sources, and meta data (includes the actual report and data source definitions)

• Resources (includes images associated with reports)

• Snapshots (includes the current data for snapshot reports)

• Report history (includes previous snapshot reports)

• The following items are stored in the ReportSeverTempDB database: • Session cache (a user-specific report cache)

• Cached instances (the report cache for multiple users)

• In the ReportServer database, the ChunkData table contains the snapshots and report history. In the ReportServerTempDB database, another ChunkData table contains the report session cache and report cached instances. Both tables store the intermediate format of reports, which means they contain the actual report data and will therefore consume a large percentage of the overall size of each database. These two ChunkData tables are a main factor in estimating your database sizes, which is described in the next topic.

Page 257: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-21

Determining Disk Space Requirements

Before you install Reporting Services, you will need to estimate the size of your report server databases so that you can plan any additional hardware requirements.

Key Points • To determine disk space requirements for your ReportServer and

ReportServerTempDB databases, consider the following general estimation guidelines: 1. Estimate the total number of reports.

2. Examine the intermediate report size.

3. For the ReportServer database, you need to factor in the persistence of the intermediate reports. Consider the following:

• Snapshots: Should only one snapshot be allowed at any point in time?

• Report history: How long is report history maintained and how frequently is history added?

4. For the ReportServerTempDB database, you need to factor in session caching. Consider the following:

• Cached instances are limited to one instance per combination of report parameters, according to expiration settings.

• Number of users affects the size of the session cache.

• Session cache timeout affects the length of time that items are held in the session cache.

Page 258: 2793A-ENU_TrainerWorkbook

8-22 Module 8: Administering Reporting Services

Defining a Backup and Restore Strategy

You will need to implement a backup and restore strategy for your report server databases. Additionally, you must back up the key used to encrypt content stored within each database. This will help you recover from any unexpected failures.

Key Points • Because ReportServer and ReportServerTempDB are SQL Server databases, the

primary mechanism for backup and restore is SQL Server backup and restore. Backup is considered mandatory for the ReportServer database because it contains the report and data source definitions. You can use the SQL Server Maintenance Plan Wizard to schedule the backups. However, the ReportServerTempDB database can be recreated when users return to a report, so backup is not necessary.

• Each report server database encrypts stored user password and connection information. A symmetric key is used to encrypt this sensitive data. To manage the cryptographic key, use the Reporting Services Configuration Management tool or the encryption key management command line utility, rskeymgmt.exe. These tools back up the encryption keys to a file hashed with a password that you provide. Store this file in a secure location; you will need it to restore the report server after certain operations, including: • Changing the report server Web service user account.

• Changing the SQL Server instance name.

• Changing the computer name of an installation.

Page 259: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-23

Lesson 4: Security Administration

Objectives After completing this lesson, you will be able to:

• Describe the Reporting Services authorization model. • Assign roles. • Work with item role definitions. • Secure items. • Work with system-level role definitions. • Secure the system.

Page 260: 2793A-ENU_TrainerWorkbook

8-24 Module 8: Administering Reporting Services

The Reporting Services Authorization Model

Reporting Services uses authorization to ensure that only appropriate users can view individual reports or author new reports. You will also need to limit access to various features of the Report Manager, such as maintaining shared schedules.

Key Points • The role-based security model supplied by Reporting Services is similar to that of

other role-based security models used in other technologies, such as .NET development and SQL Server. The basic premise of role-based security is the ability to categorize users into groups (or roles) according to how they interact with a specific system and its resources. Report Manager allows you to administer a list of user permissions by linking a user or Windows group to a role. For example, you can add a user to the Browser role, which allows the user to view reports. Other Reporting Services roles are described in the following topics. This approach provides a highly flexible and scalable security framework that enables you to manage the membership of a role instead of managing the security of each user individually.

• Reporting Services relies on the authentication capabilities of the underlying network. In other words, Reporting Services does not authenticate users. By default, Reporting Services integrates with Windows authentication. However, you can replace the default security extension with a custom or third-party module if required.

Page 261: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-25

Assigning Roles

In Reporting Services, you administer security by creating role assignments in Report Manager. Assigning a role involves choosing appropriate tasks for that role and linking the role to users or groups and securable objects.

Both SQL Server Management Studio and Report Manager provide the ability to modify roles, add new roles, and assign the roles to users or groups and securable objects. The remaining topics in this lesson will describe how to set these security options.

Key Points • A role assignment is a security policy that defines the tasks that users or groups can

perform on specific items or branches of the report server folder hierarchy. Reporting Services provides predefined roles that you can use; you can also create your own roles. Reporting Services also defines a list of predefined tasks that you cannot add to or modify. These mutually exclusive tasks cover the full range of user and administrator actions, such as viewing reports, managing reports, and managing report server properties. Tasks fall into one of the following categories: • Item tasks. Tasks that relate to a report, folder, resource, or shared data source.

Examples of item tasks include managing reports, managing folders, and managing subscriptions.

• System tasks: Tasks that apply to the report server site as a whole. Examples of system tasks include managing shared schedules and managing jobs.

• Role assignment consists of the following three components:

Page 262: 2793A-ENU_TrainerWorkbook

8-26 Module 8: Administering Reporting Services

• Windows user account or group. A user will receive permissions from all groups that he or she belongs to, in addition to any permissions granted to the user account itself.

• Role definition. The role definition specifies the set of allowable item or system tasks.

• Securable object. This includes an item object, such as a report, or a system-level object, such as a shared schedule.

Page 263: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-27

Working with Item Role Definitions

A role definition is a named collection of tasks that defines the type of access available to a user. Working with roles simplifies administration when compared to setting permissions on a user-by-user basis.

Key Points • You can create your own roles if none of the predefined roles provides you with your

required task grouping. Report Manager allows you to create item-level roles using the following steps: 1. Navigate to the Site Settings page.

2. Click Configure item-level role definitions, and then click New Role.

3. Enter Type a role name and description in the Name and Description text boxes.

4. Select the appropriate tasks from the list, and then click OK.

You can then assign this new role to a user or group by using the New Role Assignment page within the individual item that needs to be secured.

• Reporting Services provides four predefined item-level roles that you can modify as appropriate by using Report Manager: • Browser. Enables users to run reports and navigate through the folder structure.

Examples of tasks included in this role are:

• Viewing reports

• Viewing resources

• Viewing folders

Page 264: 2793A-ENU_TrainerWorkbook

8-28 Module 8: Administering Reporting Services

• My Reports. Enables users to build reports for personal use or store reports in a user-owned folder. Examples of tasks included in this role are:

• Creating linked reports

• Managing folders

• Managing data sources

• Publisher. Enables users to publish content to the report server database. Examples of tasks included in this role are:

• Managing reports

• Managing data sources

• Creating linked reports

• Content Manager. Enables users to deploy reports, manage shared data source connections, and set security at the item level. Examples of tasks included in this role are:

• Creating linked reports

• Managing subscriptions

• Managing reports

• Managing report history

Page 265: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-29

Securing Items

When you assign roles, you must specify which securable item you intend to grant access to. You can choose to secure items individually or as a group.

Key Points • Individual items that you can secure include:

• Reports. You can control whether a report is visible to users as well as whether users can change the report properties. Note that you can only secure snapshots and report history through their parent reports.

• Data sources. You can secure shared data sources to limit which users can modify the data source settings.

• Resources. Only standalone resources can be secured as individual items. Note that you cannot secure embedded resources separately from a report.

• Grouping items together into folders provides a simpler mechanism for security, because you do not have to secure several individual items. Folder security will apply to the folder itself as well as the items it contains, including subfolders. The Home folder is the root node of the folder hierarchy. Setting security for this folder establishes the initial security settings for all subsequent folders, reports, resources, and shared data sources in the folder hierarchy.

• To secure an item, you must link the user or group account to a role (or roles) on an individual item basis. Using Report Manager, follow these steps to secure an item: 1. Open the Properties page for the individual item and display the Security

properties.

2. Click New Role Assignment.

Page 266: 2793A-ENU_TrainerWorkbook

8-30 Module 8: Administering Reporting Services

3. Type the user or Windows group name and select the appropriate roles. When you click OK, Reporting Services validates the user or Windows group name and displays an error message if the account is invalid.

Page 267: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-31

Working with System-Level Role Definitions

For system-level security, roles affect the overall security of the report server site, not just individual items. You can administer these permissions by using the predefined system-level roles or by creating your own roles.

Key Points • You can create new system-level roles by copying one of the predefined roles or by

creating a new role. Report Manager enables you to create roles using the following steps: 1. Navigate to the Site Settings page.

2. Click Configure system-level role definitions.

3. Follow the same procedures as for item-level role definitions, as described in the earlier topic “Securing Items”.

You can then assign this new role to a user or group using the System Role Assignments page.

• Reporting Services supplies two predefined system roles that you can modify: • System User. Enables users to view schedule information in a shared schedule

and view other basic information about the report server. Examples of tasks included in this role are:

• Viewing report server properties

• Viewing shared schedules

Page 268: 2793A-ENU_TrainerWorkbook

8-32 Module 8: Administering Reporting Services

• System Administrator. Enables users to manage features and set defaults, set site-wide security, define role definitions, and manage jobs. Examples of tasks included in this role are:

• Managing jobs

• Managing report server properties

• Managing shared schedules

Using Report Manager, you can edit these predefined system-level roles and any new roles by using the following steps: 1. Navigate to the Site Settings page, and then click Configure system-level role

definitions.

2. Click the role that you wish to edit.

3. Change the appropriate information, and then click OK.

Page 269: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-33

Securing the System

You can secure the report server site through system role assignments. This enables you to determine who has the ability to administer roles, manage jobs, set site properties, and so on.

Key Points • The securable object for system security is the report server site, and its settings

affect the site globally. Site-level tasks include creating shared schedules, managing jobs, and settings various properties. This level of security does not provide any form of control over individual report server items, such as reports.

• Reporting Services does not create its own user accounts. Instead, it references existing local or domain accounts and groups defined in the operating system. If you inadvertently set role assignments in a way that locks all users out of the system, a local administrator can always reset security. As a precaution against a lockout situation, members of the local Administrators group can always access a report server to change site settings, no matter what role assignments are set. These site settings include system role assignments, item-level role definitions, and system-level role definitions. Note that having access to a report server is not the same as having full access to all the reports and data it contains. To ensure that highly privileged users such as local administrators cannot access confidential reports, you must secure the reports at the data-access level, requiring users to provide credentials to view the report.

• In order to secure the site, you must link the user or group account to a system-level role (or roles). Using Report Manager, follow these steps to link an account to a system-level role:

Page 270: 2793A-ENU_TrainerWorkbook

8-34 Module 8: Administering Reporting Services

1. Open the Site Settings page and click Configure site-wide security.

2. Click New Role Assignment.

3. Type the user or Windows group name and select the appropriate roles. When you click OK, Reporting Services validates the user or Windows group name and displays an error message if the account is invalid.

Page 271: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-35

Lab: Administering Reporting Services

After completing this lab, you will be able to:

• Backup and restore encryption keys. • Enforce site security using roles. • Enforce item security using roles.

Estimated time to complete this lab: 45 minutes

Lab Setup For this lab, you will use the available virtual machine environment. Before you begin the lab, you must:

• Start the 2793A-MIA-SQL-08 virtual machine. • Log on to MIAMI by using the user name Student and the password Pa$$w0rd.

Lab Scenario The Adventure Works team has asked you to publish a number of pre-written reports to a report server, and then to configure site security. You are also required to back up the site’s encryption keys.

Page 272: 2793A-ENU_TrainerWorkbook

8-36 Module 8: Administering Reporting Services

Exercise 1: Using Reporting Services Configuration Manager In this exercise, you will use the Reporting Services Configuration Manager to view Reporting Services settings and to back up the Reporting Services encryption keys.

Tasks Supporting information

1. View Reporting Services settings.

• Open the Reporting Services Configuration tool and connect to the MSSQLSERVER instance on MIAMI.

• View the settings in the various configuration pages.

2. Back up the Reporting Services encryption keys.

• Use Reporting Services Configuration to back up the encryption keys. • Set the password to Pa$$w0rd. • Save the keys as Keys.snk in the D:\Labfiles\Starter folder.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 273: 2793A-ENU_TrainerWorkbook

Module 8: Administering Reporting Services 8-37

Exercise 2: Securing a Reporting Services Site In this exercise, you will deploy the Adventure Works sales reports to the report server. You will then secure the Reporting Services site using system-level security. You will create a new role that allows several tasks and link the role to a Windows group. Finally, you will test the role by using Report Manager as a user who is a member of the Windows group.

Tasks Supporting information

1. Set up the lab environment.

• Execute the runScripts.bat batch file in the D:\Labfiles\Starter folder.

2. Open and deploy the Sales Reports solution.

• The Sales Reports.sln solution is in the D:\Labfiles\Starter folder.

3. Configure the AdventureWorks Data Source.

• Open Microsoft Internet Explorer® and browse to http://miami/reports to open Report Manager

• The AdventureWorks data source is in the Sales Reports folder. • Configure the credentials as follows.

• The credentials should be stored securely in the report server. • Use the user name MIAMI\Student, and the password

Pa$$w0rd. • The credentials should be used as Windows credentials when

connecting to the data source.

4. Open Report Manager as the NADirector user.

• Right-click Internet Explorer, and then click Run as. • Use the user name MIAMI\NADirector, and the password

Pa$$w0rd. • Navigate to http://miami/Reports. • Verify that the user has no permissions.

5. Create a new role. • Open Report Manager. • Configure the server-wide security site settings to create a new role

named Security Manager. • The Security Manager role should be able to perform only the

Manage report server security and Manage roles tasks.

6. Assign the new role to the AWSalesDirectors group.

• Assign the MIAMI\AWSalesDirectors group to the Security Manager role.

7. View site settings as the NADirector user.

• Right-click Internet Explorer, and then click Run as. • Use the user name MIAMI\NADirector, and the password

Pa$$w0rd. • Navigate to http://miami/Reports. • Click Site Settings and note that only the Security section is

available.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 274: 2793A-ENU_TrainerWorkbook

8-38 Module 8: Administering Reporting Services

Exercise 3: Securing Items In this exercise, you will add item browsing permissions to the AWSalesDirector group by using the Browser role. Finally, you will test the role using Internet Explorer.

Tasks Supporting information

1. Assign the item permissions.

• Use Report Manager to: • Assign the MIAMI\AWSalesDirectors group to the Browser

role in the Home folder. • Delete the MIAMI\AWSalesDirectors group role assignment

from the Samples folder.

2. Browse reports as the NADirector user.

• Right-click Internet Explorer, and then click Run as. • Use the user name MIAMI\NADirector, and the password

Pa$$w0rd. • Navigate to http://miami/Reports.

• Note that the Samples folder link is no longer visible because you have no permissions on the Samples folder.

• View the Company Sales report in the Sales Reports folder. • Note that you cannot set any properties for the report because

you only have permission to browse.

Note: The answers to the practices and labs are on the Student Materials CD.

Lab Shutdown After you complete the lab, you must shut down the 2793A-MIA-SQL-08 virtual machine and discard any changes.

Important: If the Close dialog box appears, ensure that Turn off and delete changes is selected, and then click OK.

Page 275: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services

Table of Contents Module Overview 9-1

Lesson 1: Querying for Server Information Using a Web Service 9-2

Lesson 2: Automating Report Management 9-7 Lesson 3: Rendering Reports 9-13 Lesson 4: Creating Custom Code 9-20 Lab: Programming Reporting Services 9-24 Course Evaluation 9-31

Page 276: 2793A-ENU_TrainerWorkbook

Information in this document, including URL and other Internet Web site references, is subject to change without notice. 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, 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. 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.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

© 2007 Microsoft Corporation. All rights reserved.

Microsoft, BizTalk, Excel, Expression, Internet Explorer, Outlook, PowerPoint, SharePoint, SQL Server, Visual Basic, Visual C#, Visual Studio, Windows and Windows Server 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.

Version 1.1

Page 277: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-1

Module Overview

Objectives After completing this module, you will be able to:

• Query server information using a Web service. • Automate report management. • Render reports. • Create custom code.

Page 278: 2793A-ENU_TrainerWorkbook

9-2 Module 9: Programming Reporting Services

Lesson 1: Querying for Server Information Using a Web Service

Objectives After completing this lesson, you will be able to:

• Describe Web services. • Describe Web service functionality. • Use Web services.

Page 279: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-3

What Are Web Services?

Reporting Services uses Web services to enable you to view and manage reports. Before you look at the individual details of the Reporting Services Web services, you must understand the basics of the underlying technology.

Key Points • Web services enable communication between applications over open protocols by

using standard data formats. This enables client and server applications to run on whatever platform is most suitable. Web services do not rely on any one platform. Instead, they rely on the following standards to enable platform independence: • Extensible Markup Language (XML): Provides a standard data presentation

• SOAP: Provides a standard format for packaging data

• HTTP: Provides a standard protocol for sending and receiving data packets

The above standards are set by the World Wide Web Consortium (http://www.w3c.org). Also known as the W3C, the World Wide Web Consortium is an independent organization composed of approximately 375 members. Any platform that can read and write XML and transport data over HTTP can use Web services. This flexibility provides the opportunity for integration with most applications platforms.

• Web services can be called from any type of application, including Microsoft® Windows® and Web applications. Applications can be developed in any programming language by any vendor as long as they can interact with Web services. The Microsoft .NET Framework also provides underlying technology to communicate with Web services.

Page 280: 2793A-ENU_TrainerWorkbook

9-4 Module 9: Programming Reporting Services

Web Service Functionality

Reporting Services provides a Web service that allows you to request and discover report server information. This information may be useful in a number of custom applications, for both viewing report information and managing the reports themselves.

Key Points • You can programmatically determine which reports are available for a particular user,

whether those reports require parameters, and other pertinent information about the reports. For example, this is how the Report Manager Web site works with reports.

• In addition, you can programmatically change a report's attributes as part of an application to manage reports. However, before you change to the new attributes of a report, your application may need information about the report’s current attributes. You can also work with subscriptions and security settings by retrieving server information.

• The primary mechanism for getting information about Reporting Services items is by communicating with the Report Server Web service, which is accessible by using standard SOAP calls. The .NET infrastructure makes it easy to write applications that communicate with a Web service, as you will see in the remainder of this module.

Page 281: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-5

Using Web Services

To retrieve server information about reports, you must follow some basic procedures to use the Web service. The following steps assume that you are using a .NET Framework application as the client.

Key Points • The first step in using the Reporting Services Web service for management is to add

a Web reference to the Web service. Adding the Web reference creates a proxy class that translates normal method calls into the appropriate SOAP calls, which are then sent to the Web service. To create a Web reference in Microsoft Visual Studio® 2005, open your client project. On the Project menu, click Add Web Reference. The Add Web Reference dialog box requires the URL that contains the programmatic description of the Web service, known as the WSDL (Web Services Description Language). The URL should be in the format http://server/reportserver/reportservice2005.asmx?wsdl. There is a second WSDL file that describes the report execution Web service; this is described later in this module.

• The proxy class called ReportingService2005 is created automatically for you when you add a Web reference. However, you must establish security credentials before you call any methods on the Report Server Web service by instantiating a proxy object and setting the Credentials property. The following code example shows how to use the default credentials of the logged-on user.

Dim rs as New ReportingService2005 rs.Credentials = System.Net.CredentialCache.DefaultCredentials

Page 282: 2793A-ENU_TrainerWorkbook

9-6 Module 9: Programming Reporting Services

• After you have added a Web reference and set the credentials for the proxy class appropriately, you can use the proxy class to retrieve whatever information you need by using the Report Server Web service. When you retrieve information about reporting items, you are not limited to reports. You can also retrieve information about other items on the server, most notably folders that organize reports. You can search for information by using the following methods: • Search for items using the FindItems method of the proxy class. This method

allows you to filter all or part of the hierarchy by using search conditions. When you create a search condition, you compare certain key attributes of the reporting items, such as name, create date, or modify date. When you search for items, the returned list is filtered by the authenticated user’s permissions.

• Navigate items in the hierarchy using the ListChildren method of the proxy class. This method allows you to navigate through the folder hierarchy by working with each item in the folder structure.

Page 283: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-7

Lesson 2: Automating Report Management

Objectives After completing this lesson, you will be able to:

• Describe what can be automated. • Use Web services to automate Reporting Services. • Use scripts to automate Reporting Services.

Page 284: 2793A-ENU_TrainerWorkbook

9-8 Module 9: Programming Reporting Services

What Can be Automated?

Reporting Services provides automation capabilities by using the same Web service described in the preceding lesson for browsing information.

Key Points • When you automate report management by using the Report Server Web service, you

can perform operations identical to those that are performed in Report Manager. This is because Report Manager uses the Web service to carry out all of its tasks. Therefore, you can write custom code to add or delete reports and folders, administer security settings or schedules, or any other task that Report Manager can perform.

• Any report management task that you must execute multiple times is ideally suited for use as a custom application. Consider the following examples of report management automation: • Applying identical settings to multiple servers when you run a report server farm.

• Applying the same security or subscription settings to multiple reports.

Page 285: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-9

Automation By Using Web Services

In order to use the management Report Server Web service for automation, you must follow the same steps as for browsing server information described previously.

Key Points • There are over 80 methods that you can use for automating report management. Most

of these methods can be broken down into the five categories: • Create. Allow creation of items

• Delete. Allow deletion of items

• Get. Allow retrieval of item properties

• List. Return lists of information

• Set. Update item properties

• The following code example shows how to upload a report using the Web service.

Dim report As Byte() = File.ReadAllBytes("Report.rdl") Dim rs As New ReportingService2005 rs.Credentials = System.Net.CredentialCache.DefaultCredentials rs.CreateReport("My Report", "/Samples", True, report, Nothing)

The preceding code example loads the report file into an array of bytes and then opens the Web service. The security credentials are assigned to the proxy object and then the CreateReport method is called. The CreateReport parameters are specified as follows:

• Report. The name of the report.

• Parent. Which parent folder the report should be located within.

Page 286: 2793A-ENU_TrainerWorkbook

9-10 Module 9: Programming Reporting Services

• Overwrite. Whether to overwrite an existing report if one is found.

• Definition. The byte array containing the report definition.

• Properties. Any additional properties the report requires.

Page 287: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-11

Automation by Using Scripts

Windows applications are very useful when you require complex user interaction to manage the report server. However, there will be times when you do not need this level of interactivity.

Key Points • Rather than write a complete executable application to carry out a management task,

you can create a script file and then use the rs.exe utility to execute the script. The rs.exe utility manages the SOAP interface and the connection to the Web service. It also manages the necessary authentication.

• The rs.exe utility requires a script file in order to manage a report server. Scripts are VB Scripts with Main function, saved with the .rss extension. You then pass the file name as parameter to rs.exe to execute the script.

• The following example shows how to list items in a file called list.rss.

Public Sub Main() Dim items() As CatalogItem items = rs.ListChildren("/", True) For Each item As CatalogItem In items Console.WriteLine(item.Name) Next item End Sub

The Main method is executed and the variable rs is automatically created to represent the proxy object. Note that no authentication is required, because the call to rs.exe performs this step. You can execute this script file using the following command.

rs.exe -i list.rss -s http://localhost/ReportServer

Page 288: 2793A-ENU_TrainerWorkbook

9-12 Module 9: Programming Reporting Services

The rs.exe utility expects an input file and a server URL as the minimum information. It will automatically use Windows authentication during the script execution.

Page 289: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-13

Lesson 3: Rendering Reports

Objectives After completing this lesson, you will be able to:

• Render reports using URL access. • Render reports using Web services. • Render reports using Web parts. • Render reports using ReportViewer.

Page 290: 2793A-ENU_TrainerWorkbook

9-14 Module 9: Programming Reporting Services

Rendering Reports by Using URL Access

Displaying reports from a company Web site is one of the most common requirements for a report server. Any Web page can link directly to reports or folders by using the item’s URL. This allows both Internet and intranet sites to render reports in a browser.

Key Points • To access reports from a Web page, create a hyperlink on a Web page that points to a

report or folder URL, and users can then view the report output. You must specify the server location, the report server virtual directory, and the report name, including the folder hierarchy as appropriate. You must also append the special parameter rs:Command=Render to the URL to render the report. If you specify a folder rather than a report, it displays a simple page with available subfolders and reports. The following URL example shows the server name as localhost, the report server virtual directory as ReportServer, the folder as Reports, and the report as Sales.

http://localhost/ReportServer?/Reports/Sales&rs:Command=Render

• You can control how a report renders in the browser by using various URL access parameters. These parameters can control features such as whether to display the report toolbar in the browser and the zoom value of the report. The following URL example shows a report without the report toolbar, increased to a zooming level of 200%.

http://localhost/ReportServer?/Reports/Sales&rs:Command=Render&rc:Toolbar=false&rc:Zoom=200

• If a report requires query parameters, you can directly insert parameter values into the URL. A report parameter is entered into a URL as shown in the following example.

Page 291: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-15

http://localhost/ReportServer?/Reports/Sales&rs:Command=Render&SalespersonID=1232

Note: Browsers limit the length of URLs, so the amount of parameters you can pass may be affected. An alternative is to pass the parameters in a HTTP POST collection, which has no such limits. For more information, see "Using URL Access in a Web Application" in SQL Server Books Online.

• Remember that a browser sends URLs to the Web server as plain text by default. If you include anything in the URL that is confidential, such as parameters, be sure to connect to the Web server using a secure, encrypted protocol such as Secure Sockets Layer (SSL).

• When you use a URL to render a report, the Web service automatically detects the browser you are using and issues the appropriate Hypertext Markup Language (HTML) for that browser. Reporting Services supports both HTML 4.0 and 3.2, but reduced functionality will apply when the browser only supports HTML level 3.2. For example, features such as Document Maps are unavailable in a 3.2 browser.

Page 292: 2793A-ENU_TrainerWorkbook

9-16 Module 9: Programming Reporting Services

Rendering Reports by Using Web Services

Using a URL is clearly the simplest way to render a report, but there are times when you want more control programmatically. You can render a report using the execution Report Server Web service in essentially the same way that you get report item information from the management Report Server Web service as previously described.

Key Points • The ReportExecution2005 Web service provides the functionality to process and

render reports. The URL should be in the format http://server/reportserver/reportexecution2005.asmx?wsdl and creates a ReportExecutionService proxy class.

• The LoadReport method needs to be called before you call the Render method. The main parameter required is the report path, but you can also supply a history id for a specific snapshot. The Render method has several parameters, including the rendering format. The function returns the rendered report as a byte array so that you can display the report in whatever way you require. For example, you can display an HTML rendered report in a literal Web control, or you can save the report output to a file.

• The following example renders a report to an XML file.

Dim res As New ReportExecutionService res.Credentials = System.Net.CredentialCache.DefaultCredentials Dim reportPath As String = "/Reports/Company Sales" res.LoadReport(reportPath, Nothing) Dim format As String = "XML" Dim devInfo As String = Nothing Dim extension As String = Nothing Dim mimeType As String = Nothing

Page 293: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-17

Dim encoding As String = Nothing Dim warnings() As Warning = Nothing Dim streamIDs() As String = Nothing Dim result() As Byte = Nothing result = res.Render(format, devInfo, extension, mimeType, encoding, warnings, _ streamIDs) File.WriteAllBytes("report.xml", result)

The first two parameters are the report path and an XML string that contains any device-specific content required by the rendering extension. All the other parameters are output parameters and can be left as default values of Nothing (in Microsoft Visual Basic® .NET) or null (in Microsoft Visual C#®).

Tip: For more information about these parameters, view the ReportingExecutionService.Render method definition in the SQL Server Books Online.

Page 294: 2793A-ENU_TrainerWorkbook

9-18 Module 9: Programming Reporting Services

Rendering Reports by Using Web Parts

Microsoft SharePoint® services is a collaborative portal application based on the Microsoft Windows SharePoint Services platform. Reporting Services provides SharePoint Web parts so that you can view reports and explore report server contents from a SharePoint page.

Key Points • The Report Explorer Web Part enables you to navigate the report server and select a

report to view. It is essentially a scaled-down version of the Report Manager. In addition to providing a view into the report server, the Explorer enables you to subscribe to reports directly from the Web Part.

• The purpose of the Report Viewer Web Part is to display a report. The default behavior is to work in "connected" mode. This means that Viewer Web Part displays whatever report whose link you click in the Explorer Web Part. Alternatively, the Web Part can work in "standalone" mode and automatically display reports without user intervention.

Page 295: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-19

Rendering Reports by Using ReportViewer

Microsoft Visual Studio 2005 contains two report viewer controls that you can use to display Reporting Services reports as part of a custom application.

Key Points • There are two versions of the report viewer control, one for Microsoft Windows

client applications and one for ASP.NET Web applications. Both versions show a report display area, a toolbar, and a document map. The toolbar enables users to page through the report, to export the report in various formats, and to print the report locally.

• Both versions of the report viewer control have a programmable interface, so you can customize, configure, and interact with the control through code at run time. For example, you can control whether the Find controls are displayed on the report toolbar by using the ShowFindControls property of the report viewer control, as shown in the following Microsoft Visual Basic code sample.

ReportViewer1.ShowFindControls = True

• Both report viewer controls support local and report server (remote) report processing. If you use remote processing, the report data is queried and the report is rendered at the report server by using a previously designed and published report definition. The report is then passed to the report viewer control in your application. If you use local processing, your application provides the report dataset and report definition file and then processes the report on the client. A Windows Forms application reads the report definition from a file and performs report processing on the client. An ASP.NET application reads the report definition file from the Web site and performs report processing on the Web server.

Page 296: 2793A-ENU_TrainerWorkbook

9-20 Module 9: Programming Reporting Services

Lesson 4: Creating Custom Code

Objectives After completing this lesson, you will be able to:

• Describe the options for extending Reporting Services. • Describe the benefits of custom assemblies.

Page 297: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-21

Extending Reporting Services

Reporting Services provides you with most of the reporting features that you will require on a day-to-day basis. Occasionally, you might require functionality that the default installation does not provide. Fortunately, you can create additional functionality yourself, since Reporting Services is designed as an extensible architecture.

Key Points • The use of custom extensions allows you to create seamless add-ins for Reporting

Services. These are particularly useful if you are a third-party developer using Reporting Services to create a specialized solution. For example, if you have a specialized application with a proprietary data source, you can create a custom data processing extension to retrieve data from your application. Alternatively, you might want to create a reporting visualization tool that links to three-dimensional views of data.

• The major tasks that Reporting Service implements are extensions. Therefore, you can add additional customized extensions that integrate seamlessly with the native functionality of the report server. Currently, you can create new extensions based on the following extension types: • Data Processing. All data connections rely on a data processing extension. You

can add your own data processing extension for your own data sources or, alternatively, you can add additional functionality to the existing Reporting Services data processing extensions.

• Rendering. Each report render option is implemented as an individual rendering extension. You can create your own rendering extension to produce report output that matches your file types.

Page 298: 2793A-ENU_TrainerWorkbook

9-22 Module 9: Programming Reporting Services

• Delivery. Delivery extensions are responsible for delivering rendered reports. You can create your own delivery extension, such as an extension for a queuing application.

• Security. Security extensions enable you to provide a custom security model that works with Reporting Services, such as a Forms authentication model.

Page 299: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-23

Why Create Custom Assemblies?

Reporting Services can take advantage of custom .NET assemblies written by you or third-party developers. If you already have experience in programming in any .NET language, you will immediately be able to create custom .NET assemblies to use in reports.

Key Points • Custom functions can be used to encapsulate complex or detailed expressions. Rather

than build all of the logic for a complex statistical calculation in a text box expression by using Report Designer, you can encapsulate the complexities in a custom function and then call the function from the report.

• Custom functions in an assembly can use the full capabilities of the .NET Framework. For example, the custom code can be procedural and not just a single expression, which enables you to use sophisticated programming structures such as conditionals (like IF and CASE statements) and loops (like FOR and WHILE constructs).

• When you put custom functions in an assembly, you can be confident that the code is secure. (You must provide a strong key for the assembly so that no one, either maliciously or inadvertently, can change the code in the function.) Another benefit of placing logic in a custom assembly is that you can reuse the function in multiple reports.

Page 300: 2793A-ENU_TrainerWorkbook

9-24 Module 9: Programming Reporting Services

Lab: Programming Reporting Services

After completing this lab, you will be able to:

• Render reports by using a URL. • Retrieve report server information by using Web Services. • Display reports by using the Report Viewer control.

Estimated time to complete this lab: 60 minutes

Lab Setup For this lab, you will use the available virtual machine environment. Before you begin the lab, you must:

• Start the 2793A-MIA-SQL-09 virtual machine. • Log on to MIAMI by using the user name Student and the password Pa$$w0rd.

Lab Scenario You need to integrate Reporting Services reports into an existing intranet Web site at Adventure Works. You also need to create a management utility that enables report administrators to view properties of reports and folders.

Page 301: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-25

Exercise 1: Using URL Access to Display a Report In this lab, you will create a custom application that uses URL access to display a report.

Tasks Supporting information

1. Specify default values for a report URL.

• Use Visual Studio 2005 to open the ReportURL.sln solution in the D:\Labfiles\Starter\Exercise01 folder.

• Set the Text property of the following controls as follows: • ReportServerTextBox: http://miami/reportserver • FolderTextBox: /Samples/AdventureWorks Sample Reports/ • ReportNameTextBox: Company Sales

2. Implement report invocation. • Add the following constant declarations to the code page for the Default.aspx Web page.

Const RENDER_COMMAND As String = "&rs:Command=Render"

Const TOOLBAR As String = "&rc:Toolbar="

Const ZOOM As String = "&rc:Zoom="

• Add the following code to the Button1_Click event, under the create report url comment.

Dim url As String

url = ReportServerTextBox.Text + "?" + _

FolderTextBox.Text + ReportNameTextBox.Text + _

RENDER_COMMAND

• Under the redirect to report page comment, add the following code. Response.Redirect(url, True)

• Test the Web page by running the project in Debug mode and clicking Show Report.

3. Configure toolbar and zoom settings.

• Add items with the following Text property values to the combo box next to the Show Toolbar label: • True • False

• Add items with the following Text property values to the combo box next to the Zoom label: • 100 • 200

• In the code file for the Web page, add the following code under the configure toolbar and zoom comment.

url += TOOLBAR + ToolbarDropDownList.Text + _

ZOOM + ZoomDropDownList.Text

• Test the Web page by running the project in Debug mode and setting the Show Toolbar and Zoom options before clicking Show Report.

4. Add report parameters. • Add the following code underneath the conditionally add parameter comment.

If ParameterNameTextBox.Text.Length > 0 Then

url += "&" + ParameterNameTextBox.Text + "=" + _

ParameterValueTextBox.Text

End If

Page 302: 2793A-ENU_TrainerWorkbook

9-26 Module 9: Programming Reporting Services

Tasks Supporting information

• Test the Web page by running the project in Debug mode and viewing the Employee Sales Summary report with an EmpID parameter value of 285.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 303: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-27

Exercise 2: Building a Reporting Services Web Service Client In this exercise, you will create a custom application that uses the Report Server Web service to view report information.

Tasks Supporting information

1. Add a Web reference to the Report Server Web service.

• Use Visual Studio 2005 to open the ReportManager.sln solution in the D:\Labfiles\Starter\Exercise02 folder.

• Add a Web reference named ReportService for the Web service defined at the following URL:

http://miami/ReportServer/ReportService2005.asmx?wsdl

2. Add code to the form to retrieve server information.

• View frmManage.vb in code view. • At the very top of the file, add an Imports statement to the

ReportManager.ReportService namespace: • After the existing Inherits statement, create a class-level variable

called rs that references the ReportingService2005 proxy class: • Find the frmManage_Load event, and before the call to the

LoadInformation method, add code to configure the rs proxy class to use the default credentials.

• Locate the LoadInformation method and modify the code as shown. Private Sub LoadInformation()

'load information into list view

lstView.Items.Clear()

Dim myCatalogItems As CatalogItem()

myCatalogItems = rs.ListChildren("/", True)

For Each cItem As CatalogItem In myCatalogItems

Dim strValues(3) As String

strValues(0) = cItem.Name

strValues(1) = cItem.Path

strValues(2) = cItem.Type.ToString()

strValues(3) = cItem.CreatedBy

lstView.Items.Add(New ListViewItem(strValues))

Next

End Sub

• The code creates a list of all the items on the report server. It then loops through the list and displays the information in the list view control.

3. Add code to retrieve individual item information.

• Find the DisplayCurrentInfo method. • Modify the code as shown. Private Sub DisplayCurrentInfo()

Me.Cursor = Cursors.WaitCursor

'display item information in messagebox

Page 304: 2793A-ENU_TrainerWorkbook

9-28 Module 9: Programming Reporting Services

Tasks Supporting information

Dim item As ListViewItem = lstView.SelectedItems(0)

Dim strName As String = item.SubItems(0).Text

Dim strPath As String = item.SubItems(1).Text

Dim properties As [Property]()

properties = rs.GetProperties(strPath, Nothing)

Dim sb As New System.Text.StringBuilder

For Each prop As [Property] In properties

sb.Append(prop.Name & ": " & prop.Value & vbCrLf)

Next

MessageBox.Show(sb.ToString(), _

"Properties of " & strName)

Me.Cursor = Cursors.Default

End Sub

• The code retrieves information from the server about the item selected in the list view control. The information is then displayed in a message box.

4. Test the application. • Run the application in Debug mode. • When the form loads (this could take a few seconds), it should

display the list of all available items on the report server. • Select one of the reports from the list view, and then click Get Info.

• Examine the properties displayed in the message box before closing it.

• Select one of the folders from the list view, and then click Get Info. • Examine the properties displayed in the message box before

closing it.

Note: The answers to the practices and labs are on the Student Materials CD.

Page 305: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-29

Exercise 3: Using the Report Viewer Control In this exercise, you will use the Report Viewer control to display reports.

Tasks Supporting information

1. Add a Report Viewer to a Web page.

• Use Visual Studio 2005 to open the ReportURL.sln solution in the D:\Labfiles\Starter\Exercise03 folder.

• Drag a Report Viewer control from the toolbox and place it under the existing table on the Web page.

• Resize the control so that it is a suitable size to display a report in.

2. Configure the Report Viewer control.

• Add the following Imports statement to the beginning of the code file for the Default.aspx Web page.

Imports Microsoft.Reporting.WebForms

• Add the following code under the use remote processing comment.

ReportViewer1.ProcessingMode = ProcessingMode.Remote

Dim serverReport As ServerReport

serverReport = ReportViewer1.ServerReport

• Add the following code under the set the report server URL and report path comment.

serverReport.ReportServerUrl = _

New Uri(ReportServerTextBox.Text)

serverReport.ReportPath = FolderTextBox.Text + _

ReportNameTextBox.Text

• Test the Web page by running the project in Debug mode and clicking Show Report.

3. Add report parameters. • Add the following code underneath the conditionally add parameter comment.

If ParameterNameTextBox.Text.Length > 0 Then

Dim parameter As New ReportParameter()

parameter.Name = ParameterNameTextBox.Text

parameter.Values.Add(ParameterValueTextBox.Text)

'set the report parameters for the report

Dim parameters() As ReportParameter = {parameter}

serverReport.SetParameters(parameters)

End If

• Test the Web page by running the project in Debug mode and viewing the Employee Sales Summary report with an EmpID parameter value of 288.

Note: The answers to the practices and labs are on the Student Materials CD.

Lab Shutdown After you complete the lab, you must shut down the 2793A-MIA-SQL-09 virtual machine and discard any changes.

Page 306: 2793A-ENU_TrainerWorkbook

9-30 Module 9: Programming Reporting Services

Important: If the Close dialog box appears, ensure that Turn off and delete changes is selected, and then click OK.

Page 307: 2793A-ENU_TrainerWorkbook

Module 9: Programming Reporting Services 9-31

Course Evaluation

Your evaluation of this course will help Microsoft understand the quality of your learning experience.

Please work with your training provider to access the course evaluation form.

Microsoft will keep your answers to this survey private and confidential and will use your responses to improve your future learning experience. Your open and honest feedback is valuable and appreciated.

Page 308: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 1: Introduction to SQL Server Reporting Services

Table of Contents Lab: Using Reporting Services Tools 1

Exercise 1: Exploring Report Designer 1 Exercise 2: Exploring Report Manager 3

Page 309: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 1: Introduction to SQL Server Reporting Services 1

Lab: Using Reporting Services Tools Exercise 1: Exploring Report Designer

Task 1: Open the AdventureWorks solution 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then

click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, browse to the D:\Labfiles\Starter folder, and then double-click the AdventureWorks Sample Reports.sln solution.

Task 2: Explore the Sales Order Detail report 1. In Solution Explorer, double-click Sales Order Detail.rdl.

2. Click the Preview tab. Notice that the report is a parameterized report that shows the detail of a particular sales order.

Tip: Close the Output pane, and click the Auto Hide button on the panes at the sides of the report designer to make it easier to see the whole report.

3. Click the Layout tab. Notice that the report is made up of a few distinct areas:

• A header consisting of an Adventure Works image on the left, and a title on the right together with an expression to display the report parameter value.

• A rectangle containing the Bill To, Ship To and order header details.

• A table region containing the order detail together with a footer containing totals.

Task 3: Alter the Sales Order Detail report 1. In the Toolbox, drag a Textbox control and drop it just above the text box containing

the Sales Order title, aligned to the left edge.

2. Stretch the new textbox to the same width as the Sales Order title text box.

3. On the Report Formatting toolbar, click Bold, and then click Align Right.

Tip: If the Bold and Align Right buttons are not visible, click the Toolbar Options button at the right edge of the toolbar to display them.

4. In the Properties pane, click the Value property, and then in the list click Expression.

5. In the Edit Expression dialog box, click Fields (SalesOrder), and then double-click OrderDate. The following expression is added to the expression pane.

Page 310: 2793A-ENU_TrainerWorkbook

2 Lab Answer Key for Module 1: Introduction to SQL Server Reporting Services

=Fields!OrderDate.Value

6. Click OK.

7. In the Properties pane, in the Format box, type d, and then press ENTER.

Task 4: Alter the OrderDetail table region 1. On the report design surface, click the cell in the footer row of the Subtotal column

of the table at the bottom of the report.

2. In the Properties pane, click the Value property, and then click Expression in the list.

3. In the expression pane, type the following expression, and then click OK.

=sum(Fields!LineTotal.Value)

4. In the Properties pane, type c in the Format property, and then press ENTER.

5. Click the cell in the footer row of the Subtotal column, and then on the Report Formatting toolbar, click Bold, and then click Align Right.

6. Click the Preview tab, and then review your changes.

Task 5: Change report parameter available values 1. Click the Layout tab.

2. On the Report menu, click Report Parameters.

3. Under Available values, enter the following labels and values.

Label Value

SO50750 SO50750

SO50751 SO50751

SO50752 SO50752

4. Click OK.

5. Click the Preview tab.

6. In the Sales Order Number list, click SO50751, and then click View Report.

7. Close Business Intelligence Management Studio. Click Yes if you are prompted to save any items.

Page 311: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 1: Introduction to SQL Server Reporting Services 3

Exercise 2: Exploring Report Manager Task 1: Start Report Manager

1. Click Start, point to All Programs, and then click Internet Explorer.

2. In the Address text box, type http://miami/reports, and then press ENTER.

The home page for Report Manager is displayed.

Task 2: Examine the Product Catalog report 1. Click the Samples folder link.

Notice that the folder contains two subfolders.

2. Click AdventureWorks Sample Reports.

Notice that the AdventureWorks Sample Reports folder contains the following seven reports:

• Company Sales

• Employee Sales Summary

• Product Catalog

• Product Line Sales

• Sales Order Detail

• Sales Reason Comparisons

• Territory Sales Drilldown

3. Click the Product Catalog link. Notice that there is a document map on the left together with a number of catalog pictures on the right.

4. In the Document Map, if necessary, expand Product Catalog, expand Bikes, expand Mountain Bikes, and then click Mountain-100.

5. In the HTML viewer toolbar, navigate through the report by clicking Next Page.

6. In the Current Page box, type 11 and then press ENTER.

7. In the Find Text box, type saddle, and then click Find. Then view the page that was found.

Task 3: View the Company Sales report 1. On the upper left side of the screen, click the AdventureWorks Sample Reports

link.

2. Click the Company Sales report link.

Page 312: 2793A-ENU_TrainerWorkbook

4 Lab Answer Key for Module 1: Introduction to SQL Server Reporting Services

3. Browse the report. Notice that you can expand the product categories and the years to drill-down and find more detailed information.

Task 4: Export the Company Sales report to Excel 1. In the Export list, click Excel, and then click Export.

2. In the File Download dialog box, click Open.

The Sales Order report is now displayed as a Microsoft® Office Excel® file.

3. Close Excel. Click No if prompted to save any changes.

Task 5: Examine Sales Order report properties 1. In Report Manager, click the Properties tab for the Company Sales report.

2. The General tab is shown. Notice that the report name and description can be edited.

3. Click the Data Sources tab. Notice that the report uses the AdventureWorks shared data source located in the /Samples/Data Sources folder.

4. Close Microsoft Internet Explorer®.

Page 313: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 2: Authoring Basic Reports

Table of Contents Lab: Creating a Simple Report 1

Exercise 1: Creating a Basic Table Report 1 Exercise 2: Formatting Report Pages 6 Exercise 3: Adding Calculated Values 10

Page 314: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 2: Authoring Basic Reports 1

Lab: Creating a Simple Report Exercise 1: Creating a Basic Table Report

Task 1: Set up the lab environment 1. Click Start, and then click My Computer.

2. Browse to the D:\Labfiles\Starter folder, and then double-click runScripts.bat. The script executes in a console window. Wait for the console window to close before proceeding to the next task.

Task 2: Create a Reporting Services project 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then

click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to New, and then click Project.

3. In the New Project dialog box, in the Project types pane, ensure that the Business Intelligence Projects project type is selected.

4. In the Templates pane, click Report Server Project.

5. Change the Location to D:\Labfiles\Starter.

6. In the Name text box, type Product Reports, and then click OK.

Task 3: Create a shared data source 1. In Solution Explorer, right-click the Shared Data Sources folder, and then click

Add New Data Source.

Tip: If Solution Explorer is not visible, on the View menu, click Solution Explorer.

2. In the Shared Data Source dialog box, on the General tab, in the Name box, type AdventureWorksDW.

3. Click Edit, and then in the Server name box, type localhost.

4. Under Log on to the server, ensure that the Use Windows Authentication option is selected.

5. In the Select or enter a database name list, click AdventureWorksDW.

6. Click Test Connection, and then click OK.

7. Click OK to close the Connection Properties dialog box, and then click OK to close the Shared Data Source dialog box.

Page 315: 2793A-ENU_TrainerWorkbook

2 Lab Answer Key for Module 2: Authoring Basic Reports

Task 4: Create a report 1. In Solution Explorer, right-click the Reports folder, point to Add, and then click

New Item.

2. In the Add New Item dialog box, in the Templates pane, click Report. In the Name box, type Product Profitability and then click Add.

Task 5: Add a dataset 1. In design view, in the Dataset list, click <New Dataset…>.

2. In the Dataset dialog box, on the Query tab, in the Name box, type DataDetail.

Caution: Ensure that there are no spaces in the name of your dataset.

3. In the Data source box, verify that the data source is AdventureWorksDW (shared).

4. In the Query string box, type:

Select * from vProductProfitability Where Year = 2003 and MonthNumberOfYear = 1

5. Click OK.

6. On the Data tab, click the Run button. A dataset containing the query results is displayed.

7. On the File menu, click Save All.

Task 6: Add a table data region 1. Click the Layout tab.

2. In the Toolbox, double-click Table. A table is added to the report. Notice that it has placeholder rows for the table header, table detail, and table footer.

Tip: By default, the Toolbox is located on the left side of the screen. If the Toolbox is not visible, on the View menu, click Toolbox.

Task 7: Add fields to the detail row 1. In the Datasets window, expand DataDetail, and then drag the Product field and

drop it into the first cell in the Detail row.

Tip: By default, the Datasets window is located on the left side of the screen. If the Datasets window is not visible, on the View menu, click Datasets.

2. Adjust the Product column to be approximately 2 inches (5 cm) wide.

Page 316: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 2: Authoring Basic Reports 3

3. In the Datasets window, drag the SalesAmount field and drop it into the second cell in the Detail row.

4. Adjust the Sales Amount column to be approximately 2 inches (5 cm) wide.

5. In the Datasets window, drag the OrderQuantity field and drop it into the third cell in the Detail row.

6. Adjust the Order Quantity column to be approximately 1.5 (4 cm) inches wide.

Task 8: Add fields to the table footer 1. In the Datasets window, drag the SalesAmount field and drop it into the second cell

in the table footer row. Note that when you add a numeric field to a header or footer row, Report Designer automatically adds a Sum function to aggregate the values.

2. In the Datasets window, drag the OrderQuantity field and drop it into the third cell in the table footer row.

3. Click the first cell of the table footer row, type Grand Total, and then press ENTER.

4. On the File menu, click Save All.

5. Click the Preview tab. Notice that the report shows a header for each column and detail values from the source data set. A grand total is shown at the end of the report.

Task 9: Create a Product Category group 1. On the Layout tab, click the table, right-click the row icon to the left of the Detail

row (the second row), and then click Insert Group.

2. In the Grouping and Sorting Properties dialog box, set the Name to table1_Category.

Important: Group names are case-sensitive.

3. Under Group on, click the first row, and from the Expression list, click =Fields!Category.Value, and then click OK.

4. In the Datasets window, drag the Category field and drop in into the first cell in the table1_Category Header row (the second row), directly beneath the Product cell.

5. In the first cell in the table1_Category Footer row (directly above the Grand Total cell), type Category Total, and then press ENTER.

6. In the Table Footer row, click the cell that contains SalesAmount total, and then press CTRL and click the cell that contains the OrderQuantity total.

7. Right-click the selected cells, and then click Copy.

Page 317: 2793A-ENU_TrainerWorkbook

4 Lab Answer Key for Module 2: Authoring Basic Reports

8. Right-click the second cell in the table1_Category Footer row (next to the Category Total cell), and then click Paste.

Task 10: Create a Product SubCategory group 1. Right-click the row icon to the left of the Detail row, and then click Insert Group.

2. In the Name box, type table1_SubCategory.

3. Under Group on, click the first row, and from the Expression list, click =Fields!SubCategory.Value.

4. On the Sorting tab, under Sort on, click the first row, and from the Expression list, click =Fields!SubCategory.Value, and then click OK.

5. In the Datasets window, drag the SubCategory field and drop it into the first cell in the table1_SubCategory Header row (the third row).

6. In the first cell in the table1_SubCategory Footer row, type SubCategory Total (directly above the Category Total cell), and then press ENTER.

7. In the Table Footer row (last row), click the cell that contains the SalesAmount total and then press CTRL and click the OrderQuantity total.

8. Right-click the selected cells, and then click Copy.

9. Right-click the second cell in the table1_SubCategory Footer row (next to the SubCategory Total cell), and then click Paste.

Task 11: Apply basic formatting to the table 1. Click the column handle (the gray box above the column) for the Sales Amount

column.

2. In the Properties window, in the Format property box, type C0, and then press ENTER. The cells format is set to currency with no decimal places.

Tip: By default, the Properties window is located on the right side of the screen. If the Properties window is not visible, on the View menu, click Properties Window.

3. Click the column handle for the Order Quantity column.

4. In the Properties window, in the Format property text box, type N0, and then press ENTER. The cells format is set to numeric with no decimal places.

5. Click the Detail row icon to select the Detail row. On the Report Formatting toolbar, click the Background Color button, click the Web tab, click WhiteSmoke, and then click OK.

6. Click the Table Header row icon, and then press CTRL and click the Table Footer row icon. The header and footer rows are selected.

Page 318: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 2: Authoring Basic Reports 5

7. On the Report Formatting toolbar, perform the following tasks:

• Click 12pt in the Font Size list.

• Click Bold.

• Click Background Color, click the Web tab, click White, and then click OK.

• Click Foreground Color, click the Web tab, click Black, and then click OK.

8. Click the table1_Category Header row icon, and then press CTRL and click the table1_Category Footer row icon.

9. On the Report Formatting toolbar, perform the following tasks:

• Click 12pt in the Font Size list.

• Click Bold.

• Click the Background Color button, click the Web tab, click Gainsboro, and then click OK.

10. Click the table1_SubCategory Header row icon, and then press CTRL and click the table1_SubCategory Footer row icon.

11. On the Report Formatting toolbar, perform the following tasks:

• Click 11pt in the Font Size list.

• Click Bold.

Task 12: Indent row captions 1. Click the first cell in the Detail row.

2. In the Properties window, expand the Padding property group.

3. In the padding Left property text box, type 12pt.

4. Click the first cell in the table1_SubCategory Header row, and in the Properties window, in the padding Left property text box, type 12pt.

5. Click the first cell in the table1_SubCategory Footer row, and in the Properties window, in the padding Left property text box, type 12pt.

6. On the File menu, click Save All.

7. Click the Preview tab. Verify the report looks as you want it to. Correct any errors before proceeding.

Page 319: 2793A-ENU_TrainerWorkbook

6 Lab Answer Key for Module 2: Authoring Basic Reports

Exercise 2: Formatting Report Pages Task 1: Open the Product Reports solution

Note: You can omit this step if you already have the Product Reports project open from Exercise 1.

1. In SQL Server Business Intelligence Development Studio, on the File menu, point to Open, and then click Project/Solution.

2. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Product Reports folder, and then double-click the Product Reports.sln solution.

Task 2: Add a page break at the end of each category group 1. Ensure that the Product Profitability report is open in the Report Designer, and

click the Layout tab.

2. Click the table, right-click the table1_Category Footer row icon (next to the Category Total cell), click Edit Group, select Page break at end, and then click OK.

Note: When you add a page break after a grouping level, the report will start a new page at the end of each element of the group, including the last. If there is a table footer on the report, it will appear alone on the last page. Currently, it is not possible to have a page break after each group member without getting an orphan total at the end of the report.

Task 3: Add a report header to the first page of the report 1. On the Layout tab, click the table so that you can see the row and column handles,

and then click the handle in the top left corner to select the table item.

2. Drag the table down so that the top of the table is approximately 1.5 inches (4 cm) from the top of the report.

3. In the Toolbox, click Line. Drag a horizontal line across the top of the report, aligned with the width of the table.

4. In the Properties window, change the LineWidth property of the line (line1) to a value of 12pt.

5. In the Toolbox window, click Textbox. On the report grid, click just under the line in the upper left corner and drag the text box to size it 2.5in (6 cm) wide and 1.25in (4 cm) high. Reposition and resize the text box as needed.

Page 320: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 2: Authoring Basic Reports 7

Tip: You can use the Size, Width, and Height properties in the Properties window to adjust the size of the text box. After an item is selected in Layout view, you can use the arrow keys for large movements, or CTRL and arrow keys for fine movements.

6. Click inside the text box, type Adventure Works Product Profitability Report, and then press ENTER.

Tip: You can force a new line by pressing SHIFT+ENTER.

7. On the Report Formatting toolbar, in the Font Size list, click 20, and then click the Bold button to format the text box. Resize the text box as necessary so that you can see the full title on 3 lines of text.

Task 4: Add an image to the report 1. In the Toolbox window, click Image. On the report grid, click to the right of the

report title text box.

2. In the Image Wizard dialog, on the Welcome to the Image Wizard page, click Next.

3. On the Select the Image Source page, ensure that Embedded is selected, and then click Next. Note that an embedded image cannot be shared with other reports in the project.

4. On the Choose the Embedded Image page, click New Image.

5. Navigate to the D:\Labfiles\Starter folder, click logopart.jpg, and click Open.

6. Click the Name column, delete the existing text, type logopart, and then click Next.

7. On the Completing the Wizard page, click Finish. The image is added to the report.

8. Stretch and align the image as required to match the height of the Report Title text box.

9. On the File menu, click Save All.

10. Click the Preview tab. Notice that:

• The report header and image appears on the first page only.

• Each category appears on its own page.

Task 5: Add a repeating table header 1. Click the Layout tab.

2. Click the table, and then click the Table Header row icon.

3. In the Properties pane, set the RepeatOnNewPage to True.

Page 321: 2793A-ENU_TrainerWorkbook

8 Lab Answer Key for Module 2: Authoring Basic Reports

Note: Group headers and footers only appear, by default, at the beginning or ending of a group. Within the Grouping and Sorting Properties dialog box for a group, you can set an option to cause the header or footer to repeat on each new page.

4. Click the Preview tab, and notice that the product header appears in black on each report page.

Task 6: Add a page header to the report 1. Click the Layout tab.

2. Right-click the margin to the left of the report body, and then click Page Header. Notice that a new section, labeled Page Header, appears at the top of the report.

3. In the Toolbox window, click Textbox.

4. Click inside the Page Header, and size the text box to 2 inches (5 cm) wide and 0.25 inches (0.5 cm) high.

5. Drag the text box to align it with the right edge of the line.

6. With the text box selected, in the Properties window, in the Appearance section, in the TextAlign property list, click Right.

7. Click inside the text box, type Product Profitability Report, and then press ENTER.

8. In the Properties window list, click Page Header.

9. In the PrintOnFirstPage property list, set the value to False.

10. In the PrintOnLastPage property list, set the value to True.

11. Click the Preview tab. Notice that the page header is printed on every page except for the first page.

Task 7: Add a page footer to the report 1. Click the Layout tab.

2. Right-click the margin to the left of the report body, and then click Page Footer.

3. In the Toolbox, click Textbox.

4. Click inside the Page Footer, and size the text box to 1.5 inches (4 cm) wide and 0.25 inches (0.5 cm) high.

5. Click inside the text box, and then type Company Confidential.

6. On the Report Formatting toolbar, click Italic.

7. On the Layout toolbar, click Center Horizontally.

8. In the Properties window list, click Page Footer.

Page 322: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 2: Authoring Basic Reports 9

9. Ensure that the PrintOnFirstPage property is set to False, and that the PrintOnLastPage property is set to True.

10. On the File menu, click Save All.

11. Click the Preview tab, and verify that the report looks as you want it to. Notice that:

• Each category is on a different page.

• Table header and page footer are repeated on all pages of the report.

• The page header appears on all pages except the first page.

Page 323: 2793A-ENU_TrainerWorkbook

10 Lab Answer Key for Module 2: Authoring Basic Reports

Exercise 3: Adding Calculated Values Task 1: Open the Product Reports solution

Note: You can omit this step if you already have the Product Reports project open from Exercise 2.

1. In SQL Server Business Intelligence Development Studio, on the File menu, point to Open, and then click Project/Solution.

2. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Product Reports folder, and then double-click the Product Reports.sln solution.

Task 2: Create and add a calculated field for the profit margin 1. Ensure that the Product Profitability report is open in the Report Designer, and

click the Layout tab.

2. In the Datasets window, right-click DataDetail, and then click Add.

3. In the Add New Field dialog box, in the Name box, type Margin.

3. Select the Calculated field option, and then click the function button (fx).

4. In the Edit Expression dialog box, in the lower left pane, click Fields (DataDetail), and then in the lower right pane, double-click SalesAmount. The field is added to the expression in the upper pane.

5. In the upper pane, place the cursor after =Fields!SalesAmount.Value, and then type a minus sign (-).

6. In the lower right pane, double-click CostAmount. You should now see the following expression in the upper pane:

=Fields!SalesAmount.Value - Fields!CostAmount.Value

7. Click OK to close the Edit Expression dialog box, and then click OK to close the Add New Field dialog box. The Margin calculated field is added to the DataDetail dataset.

8. On the File menu, click Save All.

Task 3: Add the Margin calculated field to the report 1. On the Layout tab, right-click the column handle for the Order Quantity field, and

then click Insert Column to the Right. A new column appears with the same format as the Order Quantity column.

2. In the Datasets window, drag the Margin field, and drop it into the Detail row in the new column.

Page 324: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 2: Authoring Basic Reports 11

3. In the Datasets window, drag the Margin field, and drop it into the table1_SubCategory Footer row (directly below the detail row) in the new column. Notice that the expression becomes a Sum expression.

4. Press ENTER to select the entire expression in the last cell in the table1_SubCategory Footer row, and then press CTRL+C to copy it.

5. Click the last cell in the table1_Category Footer row. Then click the cell again to edit the empty formula. Press CTRL+V to paste the copied formula.

Note: Copying just the formula preserves the formatting in the destination cell.

6. Click the last cell in the Table Footer row (last row). Then click the cell again to edit the empty formula. Press CTRL+V to paste the copied formula.

7. Click the column handle for the Margin column. In the Properties window, in the Format property text box, replace the existing format code with C0. The cell is formatted as currency with no decimal places.

8. On the File menu, click Save All.

9. Click the Preview tab, and verify that the report looks as you want it to. Fix any errors before continuing.

Task 4: Add a margin percentage expression to the detail row 1. Click the Layout tab.

2. Right-click the handle at the top of the Margin column, and then click Insert Column to the Right.

3. In the last cell in the Table Header row, type Margin %.

4. Click the column handle for the Margin % column. In the Properties window, in the Format property box, replace the existing format code with P1.The cells are formatted as a percentage with one decimal place.

5. Right-click the Detail cell of the Margin % column, and then click Expression.

6. In the Edit Expression dialog box, type the following into the upper box:

=ReportItems!Margin.Value / ReportItems!SalesAmount.Value

7. Click OK.

8. To view the new column, click the Preview tab.

Task 5: Add a margin percentage expression to the table footer 1. Click the Layout tab.

Page 325: 2793A-ENU_TrainerWorkbook

12 Lab Answer Key for Module 2: Authoring Basic Reports

2. Click the Sales Amount cell in the Table Footer row. In the Properties window, in the Name property box, replace the existing name with SalesAmount_Total.

3. Click the Margin cell in the Table Footer row. In the Properties window, in the Name property box, replace the existing name with Margin_Total.

4. Right-click the Margin % cell in the Table Footer row, and then click Expression.

5. In the Edit Expression dialog box, in the upper box, type :

=ReportItems!Margin_Total.Value / ReportItems!SalesAmount_Total.Value

6. Click OK.

7. To view the added Margin % table footer, click the Preview tab, and then navigate to the end of the report.

Task 6: Add a margin percentage expression to the Category footer 1. Click the Layout tab.

2. Click the Sales Amount cell in the table1_Category Footer row. In the Properties window, in the Name property text box, replace the existing name with SalesAmount_Category.

3. Click the Margin cell in the table1_Category Footer row. In the Properties window, in the Name property text box, replace the existing name with Margin_Category.

4. Right-click the Margin % cell in the table1_Category Footer row, and then click Expression.

5. In the Edit Expression dialog box, in the Expression box, type:

=ReportItems!Margin_Category.Value / ReportItems!SalesAmount_Category.Value

6. Click OK.

7. Click the Preview tab. Notice that a margin percent exists for each category.

Task 7: Add a margin percentage expression to the SubCategory footer 1. Click the Layout tab.

2. Click the Sales Amount cell in the table1_SubCategory Footer row. In the Properties window, in the Name property box, replace the existing name with SalesAmount_SubCategory.

3. Click the Margin cell in the table1_SubCategory Footer row. In the Properties window, in the Name property box, replace the existing name with Margin_SubCategory.

Page 326: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 2: Authoring Basic Reports 13

4. Right-click the Margin % cell in the table1_SubCategory Footer row, and then click Expression.

5. In the Edit Expression dialog box, in the upper box, type:

=ReportItems!Margin_SubCategory.Value / ReportItems!SalesAmount_SubCategory.Value

6. Click OK.

7. Click the Preview tab. Notice that a value for margin percent now exists at subcategory level.

Task 8: Conditionally format rows with low margin percents 1. Click the Layout tab.

2. In the Detail row, click the Margin % cell.

3. In the Properties window, in the Color property list, click Expression.

4. In the Edit Expression dialog box, in the upper box, delete the default expression and type:

=IIF(Me.Value<0.15, "Red", "Black")

Note: The Me keyword refers to the report item for which the expression is being calculated. For a text box named MarginPercent, the expression Me.Value is equivalent to ReportItems!MarginPercent.Value.

5. Click OK.

Task 9: Copy conditional formatting to additional rows 1. In the Properties window, in the Color property list, click the expression, and then

press CTRL+C to copy the expression.

2. In the table1_SubCategory Footer row, click the Margin % cell.

3. In the Properties window, click the Color property, delete the existing value, and press CTRL+V to paste the expression.

4. Repeat steps 2 and 3 for the Margin % cell in the following rows:

• table1_Category Footer

• Table Footer

5. Ensure that the Margin % cell in the Table Footer row is selected. In the Properties window, in the Color property list, click Expression.

6. Modify the expression by replacing Black with White, and then click OK.

7. On the File menu, click Save All.

Page 327: 2793A-ENU_TrainerWorkbook

14 Lab Answer Key for Module 2: Authoring Basic Reports

8. Click the Preview tab, and verify that the margin percent for AWC logo cap and the Cap SubCategory Total both appear in red.

Task 10: Sort products in descending order of Sales Amount 1. Click the Layout tab.

2. Right-click the Detail row icon, and then click Insert Group.

3. In the Grouping and Sorting Properties dialog box, in the Name box, type DetailSort.

4. Under Group on, click the first row, and from the Expression list, click =Fields!Product.Value.

5. Click the Sorting tab. Under Sort on, click the first row, and from the Expression list, click =Fields!SalesAmount.Value. In the Direction column, click Descending, and then click OK.

6. On the File menu, click Save All.

7. Click the Preview tab, and verify that the report looks as you want it to. Notice that the products are listed in descending order based on sales amount.

Task 11: Show cumulative Sales Amount within SubCategory 1. Click the Layout tab.

2. Right-click the handle at the top of the Sales Amount column, and click Insert Column to the Right.

3. In the new cell in the Table Header row, type Cumulative.

4. In the Detail row, right-click the Cumulative cell, and then click Expression.

5. In the Edit Expression dialog box, in the upper pane, type:

=RunningValue(Fields!SalesAmount.Value, Sum, "table1_SubCategory")

6. Click OK. Note that this expression calculates a running total of the sales amount, resetting each time the value of the table1_SubCategory level changes.

7. On the File menu, click Save All.

8. Click the Preview tab, and verify that the report looks as you want it to. Notice the Cumulative value increases within each subcategory until it matches the total for the subcategory.

Task 12: Convert the Cumulative value to a percentage 1. Click the Layout tab.

2. In the Detail row, right-click the Cumulative cell, and then click Expression.

Page 328: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 2: Authoring Basic Reports 15

3. In the Edit Expression dialog box, in the upper pane, change the expression to:

=RunningValue(Fields!SalesAmount.Value, Sum, "table1_SubCategory") / ReportItems!SalesAmount_SubCategory.Value

4. Click OK. Note that this expression calculates the cumulative percentage of the subcategory for each product.

5. In the Properties window, in the Format property text box, type P1.

6. Change the label in the Table Header row to Cumulative %.

7. On the File menu, click Save All.

8. Click the Preview tab, and verify that the report looks as you want it to. Notice that the cumulative percentages accumulate to 100% for each subcategory and then restart with each new subcategory.

Page 329: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 3: Enhancing Basic Reports

Table of Contents Lab: Enhancing a Report 1

Exercise 1: Using Dynamic Visibility 1 Exercise 2: Using Document Maps 3 Exercise 3: Initiating Actions 5 Exercise 4: Using a List Data Region 7

Page 330: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 3: Enhancing Basic Reports 1

Lab: Enhancing a Report

Exercise 1: Using Dynamic Visibility Task 1: Set up the lab environment

1. Click Start, and then click My Computer.

2. Browse to the D:\Labfiles\Starter\Exercise01 folder, and then double-click runScripts.bat. The script executes in a console window. Wait for the console window to close before proceeding to the next step.

3. Close the folder window.

Task 2: Open the AdventureWorks solution 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then

click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, browse to the D:\Labfiles\Starter\Exercise01 folder, click AdventureWorks.sln, and then click Open.

4. In Solution Explorer, under Customer Sales, double-click Reseller Sales.rdl.

Task 3: Preview the report 1. Click the Preview tab to view the report. Notice that the report contains detail and

summarized values for resellers, subcategories, and categories, including both header and footer summaries for subcategories and categories.

Note: You can close the Output window, and Auto Hide the Solution Explorer, Properties, Datasets, and Toolbox windows to make it easier to see the report.

2. Click the Layout tab.

Task 4: Hide the Reseller detail and State footer rows 1. Click the table data region, and then click the icon to the left of the Detail row.

2. In the Properties window, expand the Visibility property, and in the Hidden property list, click True.

3. In the table data region, click the icon to the left of the State Total footer row.

4. In the Properties window, under the Visibility property, in the Hidden property list, click True.

5. On the File menu, click Save All.

Page 331: 2793A-ENU_TrainerWorkbook

2 Lab Answer Key for Module 3: Enhancing Basic Reports

6. Click the Preview tab. Notice that the detailed reseller rows and state footers are hidden.

Task 5: Toggle the visibility of the hidden rows 1. Click the Layout tab.

2. In the table data region, click the icon to the left of the Detail row.

3. In the Properties window, under the Visibility property, in the ToggleItem property list, click State.

4. In the table data region, click the icon to the left of the State Total footer row.

5. In the Properties window, under the Visibility property, in the ToggleItem property list, click State.

6. On the File menu, click Save All.

7. Click the Preview tab.

8. Click the plus sign next to Connecticut to view the resellers for this state. Notice that the plus sign allows you to drill down and view the detailed reseller and state total footer rows.

Task 6: Show State totals when the detail is hidden 1. Click the Layout tab.

2. In the State Total footer row, click the Sales Amount cell, and then press SHIFT and click the Margin % total cell. Right-click the selected row, and then click Copy.

3. In the State header row (row 3), right-click the SalesAmount cell, and then click Paste.

4. With the pasted cells still selected, in the Properties window, ensure that the Visibility property is expanded, and then in the ToggleItem property list, click State.

Important: Make sure to keep the Hidden property set to False. Toggling visibility will hide the data values from the fields.

5. On the File menu, click Save All.

6. Click the Preview tab.

7. Click the plus sign next to Texas to view the resellers for this state. Notice that the data next to Texas in the State header row is now hidden when you drill down.

8. On the File menu, click Close Project.

Page 332: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 3: Enhancing Basic Reports 3

Exercise 2: Using Document Maps Task 1: Open the Document Map solution

1. If Business Intelligence Development Studio is not already open, click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise02 folder, click Document Map.sln, and then click Open.

4. In Solution Explorer, under Document Map, double-click Product Catalog.rdl

Task 2: Preview the report 1. Click the Preview tab (ignore any warnings displayed when the report is built).

2. On the left side of the report, in the Document Map window, expand Product Catalog, and then click Clothing to navigate to the clothing products.

Task 3: Add a label to the group in SubCategoryList 1. Click the Layout tab.

2. In the Properties window list, click SubCategoryList.

3. In the Grouping property, click the ellipsis.

4. In the Grouping and Sorting Properties dialog box, in the Document map label list, click =Fields!ProdSubCat.Value, and then click OK.

Note: By adding a label to the group in the list, you are adding this report item to the document map.

Task 4: Add a label to the group in ModelList 1. In the Properties window list, click ModelList.

2. In the Properties window, in the Grouping property, click the ellipsis.

3. In the Grouping and Sorting Properties dialog box, in the Document map label list, click =Fields!ProdModel.Value, and then click OK.

Page 333: 2793A-ENU_TrainerWorkbook

4 Lab Answer Key for Module 3: Enhancing Basic Reports

Task 5: Save and preview the report 1. On the File menu, click Save All.

2. Click the Preview tab.

3. On the left side of the report, in the Document Map window, expand Product Catalog, expand Clothing, expand Jerseys, and then click Short-Sleeve Classic Jersey. Notice that subcategory and model groups are now contained in the document map and that the matching report item is displayed in the report. (You might need to scroll through the report to see the matching report item.)

Note: The document map can be hidden by pressing the document map button directly above it.

4. On the File menu, click Close Project.

Page 334: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 3: Enhancing Basic Reports 5

Exercise 3: Initiating Actions Task 1: Set up the lab environment

1. Click Start, and then click My Computer.

2. Browse to the D:\Labfiles\Starter\Exercise03 folder, and then double-click runScripts.bat. The script executes in a console window. Wait for the console window to close before proceeding to the next step.

3. Close the folder window.

Task 2: Open the Action solution 1. If Business Intelligence Development Studio is not already open, click Start, point to

All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise03 folder, click Action.sln, and then click Open.

Task 3: Preview the report 1. In Solution Explorer, under Action, double-click Order Details.rdl.

2. Click the Preview tab (ignore any warnings displayed when the report is built). Notice that the report contains a series of orders for a single customer.

3. Click the Layout tab.

Task 4: Add an action to jump to report 1. In the Detail row of the table, click the Order column.

2. In the Properties window, in the Action property, click the ellipsis.

3. In the Action dialog box, select Jump to report.

4. In the Jump to report list, click Product Detail, and then click Parameters.

5. In the Parameter Name list, click Product.

6. In the Parameter Value list, click =Fields!Product.Value, click OK, and then click OK to close the Action dialog box.

7. With the Order cell still selected, in the Properties window, in the TextDecoration list, click Underline. This will help to emphasize the report link.

Page 335: 2793A-ENU_TrainerWorkbook

6 Lab Answer Key for Module 3: Enhancing Basic Reports

Task 5: Save and preview the report 1. On the File menu, click Save All.

2. Click the Preview tab. Click the product named Road-650 Black, 60 in the report to jump to the Product Detail report. Notice that the report is filtered by product number.

3. On the File menu, click Close Project.

Page 336: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 3: Enhancing Basic Reports 7

Exercise 4: Using a List Data Region Task 1: Set up the lab environment

1. Click Start, and then click My Computer.

2. Browse to the D:\Labfiles\Starter\Exercise04 folder, and then double-click runScripts.bat. The script executes in a console window. Wait for the console window to close before proceeding to the next step.

3. Close the folder window.

Task 2: Open the Data Regions solution 1. If Business Intelligence Development Studio is not already open, click Start, point to

All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise04 folder, click Data Regions.sln, and then click Open.

Task 3: Preview the report 1. In Solution Explorer, under Data Regions, double-click Table Product

Profitability.rdl.

2. Click the Preview tab. Notice that the report includes a table with a table header and footer, a category header and footer, and a subcategory header. The report contains no detail rows.

3. Close the report.

Task 4: Copy the report 1. In Solution Explorer, right-click Table Product Profitability.rdl, and then click

Copy.

2. Press CTRL+V to paste a copy of the report.

3. Right-click the copy of the report, and then click Rename.

4. Type List Product Profitability.rdl and then press ENTER.

5. Double-click List Product Profitability.rdl.

Task 5: Expand the height of the report 1. Click the Body header bar to select the body of the report.

2. In the Properties window, expand the Size property group. In the Height property box, replace the existing value with 5 inches (12.5 cm).

Page 337: 2793A-ENU_TrainerWorkbook

8 Lab Answer Key for Module 3: Enhancing Basic Reports

3. Click the table, and then click the table handle (at the top left of the table).

4. Drag the table to the bottom of the report.

Task 6: Add a Category list 1. In the Toolbox, click List.

2. Drag a list data region and position it 0.25 inches (0.5 cm) below the top edge of the report. Ensure that the list is the same width as the table and approximately 0.75 inches (2 cm) high.

3. Right-click the list data region and select Properties. In the Data set name list click DataDetail, and then click Edit details group.

4. In the Grouping and Sorting Properties dialog box, type list1_Category in the Name box.

5. In the Group on grid, click the first row, and in the Expression list, click =Fields!Category.Value, and then click OK.

6. On the Sorting tab, in the Sort on grid, click the first row, and in the Expression list, click =Fields!Category.Value, and then click OK.

Note: With a Table data region, you can right-click a row handle to add a new grouping level. With a List data region, there is no option for adding a new grouping level.

Task 7: Add fields to the Category list 1. In the Datasets window, expand DataDetail, drag the Category field, and then drop

it inside the bottom left corner of the list.

2. Drag the right side of the Category text box until the text box is approximately 2 inches (5 cm) wide. Resize and reposition as needed to move the text box to the upper left corner of the list.

Tip: Use the ruler at the top of the report designer as a guide when you are resizing text boxes in the list.

3. In the Datasets window, drag the SalesAmount field and drop it to the right of the Category text box inside the list. Resize the SalesAmount text box so that it is approximately 1.5 inches (4 cm) wide.

4. With the SalesAmount text box still selected, in the Properties window, in the Format property, type C0 to format the numbers as currency with 0 decimal places.

Page 338: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 3: Enhancing Basic Reports 9

5. In the Datasets window, drag an OrderQuantity field and drop it to the right of the SalesAmount field inside the list. Resize the OrderQuantity text box so that it is approximately 1.5 inches (4 cm) wide.

6. With the OrderQuantity text box still selected, in the Properties window, in the Format property, type N0 to format the information as numbers with 0 decimal places.

7. Click all three text boxes while holding down CTRL. On the Report Formatting toolbar, click the Bold button.

Task 8: Add header and footer rows 1. Hold down the CTRL key and, in the list, click the Category, SalesAmount, and

OrderQuantity text boxes.

2. Copy the selected text boxes by holding down the CTRL key as you drag the text boxes just above the list.

3. Hold down the CTRL key and, in the list, click the Category, SalesAmount, and OrderQuantity text boxes.

4. Copy the selected text boxes by holding down the CTRL key as you drag the text boxes just below the list.

5. Click all six new header and footer text boxes while holding down CTRL.

6. With the six new text boxes selected outside the list, on the Report Formatting toolbar, perform the following tasks:

• Click 12 in the Font Size list.

• Click the Background Color button, click the Web tab, click Black, and then click OK.

• Click the Foreground Color button, click the Web tab, click White, and then click OK.

7. In the Category text box above the list, replace the text with Category.

8. In the Category text box below the list, replace the text with Grand Total.

9. In the SalesAmount text box above the list, replace the text with Sales Amount.

10. In the OrderQuantity text box above the list, replace the text with Order Quantity.

11. On the File menu, click Save All.

12. Click the Preview tab. Notice that the list contains all product categories together with a grand total.

Page 339: 2793A-ENU_TrainerWorkbook

10 Lab Answer Key for Module 3: Enhancing Basic Reports

Task 9: Add SubCategory list 1. Click the Layout tab.

2. In the Toolbox window, click List.

3. Click and drag a rectangle below the Category list, leaving a 0.25 inches (0.5 cm) gap between the lists. Resize the list to be the same width as the Category list and approximately 0.25 inches (0.5 cm) high.

4. Right-click the new list data region, and then click Properties. In the Data set name list, click DataDetail, and then click Edit details group.

5. In the Grouping and Sorting Properties dialog box, type list2_SubCategory in the Name box.

6. In the Group on grid, click the first row, and in the Expression list, click =Fields!SubCategory.Value, and then click OK.

7. On the Sorting tab, in the Sort on grid, click the first row, and in the Expression list, click =Fields!SubCategory.Value, and then click OK.

Task 10: Add fields to the SubCategory list 1. In the Datasets window, drag the SubCategory field and drop it into the

SubCategory list. Drag the text box 0.25 inches (0.5 cm) from the left edge inside the SubCategory list, and resize the text box to approximately 1.75 inches (4.5 cm) wide.

2. In the category list, click the SalesAmount details textbox, and then hold down the CTRL key and click the OrderQuantity details textbox (both are found in the row with a white background).

3. Copy the selected text boxes by holding down the CTRL key as you drag the text boxes into the subcategory list to the right of the SubCategory text box.

4. With the two new SalesAmount and OrderQuantity textboxes selected in the SubCategory list, on the Report Formatting toolbar, click the Bold button to turn off boldfacing.

5. Ensure that the SalesAmount and OrderQuantity text boxes are horizontally aligned.

6. On the File menu, click Save All.

7. Click the Preview tab. Notice that there are two lists: the first has a header and footer and contains categories; the second contains a list of subcategories.

Tip: If you see repetitions of a header or footer element, you might have inadvertently moved a text box into one of the lists. To check whether a text box is in a list, choose the list’s name from the list in the Properties window to make the list’s boundary visible.

Page 340: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 3: Enhancing Basic Reports 11

Task 11: Combine the Category and SubCategory lists. 1. Click the Layout tab.

2. Drag the subcategory list, and drop it inside the category list, just below the row containing the Category, SalesAmount and OrderQuantity text boxes. Ensure that the SalesAmount and OrderQuantity columns in the subcategory list are aligned with the SalesAmount and OrderQuantity columns in the categories list.

The report should now contain:

• A row of text boxes containing the text Category, Sales Amount, and Order Quantity.

• A list data region that contains:

• A row of textboxes with the values =Fields!Category.Value, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

• A second list data region containing row of text boxes, which in turn contain the values =Fields!SubCategory.Value, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

• A row of textboxes under the category list containing the values Grand Total, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

• The table from the original Table Product Profitability.rdl report.

3. Select the Category, SalesAmount and OrderQuantity text boxes in the category list by holding down the CTRL key and clicking them. Then copy them below the subcategory list by holding down the CTRL key as you drag and drop them. Ensure that you drop the copied textboxes below the subcategory list, but still in the category list. (You might need to resize the category list and move the total text boxes under the list if there is not enough space.)

The report should now contain:

• A row of text boxes containing the text Category, Sales Amount, and Order Quantity.

• A list data region that contains:

• A row of textboxes with the values =Fields!Category.Value, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

• A second list data region containing row of text boxes, which in turn contain the values =Fields!SubCategory.Value, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

Page 341: 2793A-ENU_TrainerWorkbook

12 Lab Answer Key for Module 3: Enhancing Basic Reports

• A second row of textboxes with the values =Fields!Category.Value, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

• A row of textboxes under the category list containing the values Grand Total, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

• The table from the original Table Product Profitability.rdl report.

4. Remove the SalesAmount and OrderQuantity text boxes in the first row of the category list (the totals are now displayed in the row under the subcategory list instead).

5. Replace the expression =Fields!Category.Value in the row under the subcategory list with the text Category Total.

The report should now contain:

• A row of text boxes containing the text Category, Sales Amount, and Order Quantity.

• A list data region that contains:

• A textbox with the value =Fields!Category.Value.

• A second list data region containing row of text boxes, which in turn contain the values =Fields!SubCategory.Value, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

• A row of textboxes with the values Category Total, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

• A row of textboxes under the category list containing the values Grand Total, =Sum(Fields!SalesAmount.Value), and =Sum(Fields!OrderQuantity.Value).

• The table from the original Table Product Profitability.rdl report.

Task 12: Delete the table version of the report 1. Click the table, then right-click the top left grey cell, and then click Delete.

2. On the File menu, click Save All.

3. Click the Preview tab to preview the completed report.

4. Close the solution.

Page 342: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 4: Manipulating Data Sets

Table of Contents Lab: Manipulating Data Sets 1

Exercise 1: Using Parameters to Restrict Query Results 1 Exercise 2: Using Parameters to Filter Report Data 4 Exercise 3: Creating Dynamic Parameter Lists 7 Exercise 4: Using Parameters with a Stored Procedure 10 If Time Permits: Displaying All Categories in a Parameter List 12

Page 343: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 4: Manipulating Data Sets 1

Lab: Manipulating Data Sets Exercise 1: Using Parameters to Restrict Query Results

Task 1: Set up the lab environment 1. Click Start, and then click My Computer.

2. Browse to the D:\Labfiles\Starter\Exercise01 folder, and then double-click runScripts.bat. The script executes in a console window. Wait for the console window to close before proceeding to the next step.

3. Close the folder window.

Task 2: Open the Data Manipulation solution 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then

click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, browse to the D:\Labfiles\Starter\Exercise01 folder, click Data Manipulation.sln, and then click Open.

4. In Solution Explorer, under Data Manipulation, double-click Product Profitability.rdl.

5. Click the Preview tab. Notice that the report is hard-coded to display data for January 2003. The user cannot change the date used in the report.

Note: You can close the Output window, and Auto Hide the Solution Explorer, Properties, Datasets, and Toolbox windows to make it easier to see the report.

Task 3: Modify the data set query 1. Click the Data tab.

2. In the SQL pane, replace the numeric constants for Year and Month with the parameters @Year and @Month. You should now have the following SQL statement in the SQL pane.

SELECT Product, SubCategory, CategoryKey, Category, CostAmount, SalesAmount, OrderQuantity, Month, MonthNumberOfYear, Year

FROM vProductProfitability WHERE (Year = @Year) AND (MonthNumberOfYear = @Month)

3. On the File menu, click Save All.

Page 344: 2793A-ENU_TrainerWorkbook

2 Lab Answer Key for Module 4: Manipulating Data Sets

Task 4: Edit the Year and Month parameters 1. Click the Layout tab.

2. On the Report menu, click Report Parameters. Notice that the Month and Year report parameters have been created automatically.

3. Perform the following steps to edit the Year parameter:

In the Parameters pane, click the Year parameter.

In the Default values section, select the Non-queried option. A default values text box appears.

In the Default values text box, type 2003.

Tip: If you want the default value of the Year parameter to be dynamically based upon the current year, use the expression =Year(Now).

4. Perform the following steps to edit the Month parameter:

a. In the Parameters pane, click the Month parameter.

b. In the Available values section ensure that the Non-queried option is selected.

c. Type the following values in the Available values grid.

Label Value

Jan 1

Feb 2

Mar 3

Apr 4

May 5

Jun 6

d. In the Default values section, select the Non-queried option.

e. In the Default values text box, type 1.

Tip: If you want the default value of the Month parameter to be dynamically based upon the current month, use the expression =Month(Now).

5. Click OK to close the Report Parameters dialog box.

Task 5: Save and preview the report 1. On the File menu, click Save All.

2. Click the Preview tab. Notice that a Year text box and a Month drop-down list appear at the top of the report.

Page 345: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 4: Manipulating Data Sets 3

3. In the Month list, click Jun, and then click View Report.

4. On the File menu, click Close Project.

Page 346: 2793A-ENU_TrainerWorkbook

4 Lab Answer Key for Module 4: Manipulating Data Sets

Exercise 2: Using Parameters to Filter Report Data Task 1: Open the Data Manipulation solution

1. If Business Intelligence Development Studio is not already open, click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise02 folder, click Data Manipulation.sln, and then click Open.

4. In Solution Explorer, under Data Manipulation, double-click Product Profitability.rdl.

Task 2: Add a data set for the Category parameter 1. Click the Data tab.

2. In the Datasets list, click <New Dataset…>.

3. In the Datasets dialog box, on the Query tab, in the Name text box, type Category.

4. In the Data source list, verify that the data source is AdventureWorksDW, and then click OK.

5. In the SQL pane (the top pane in the Data tab), type the following SQL statement.

SELECT DISTINCT EnglishProductCategoryName AS Category FROM DimProductCategory

6. Click the Run button to execute the query. Correct any errors before continuing.

Task 3: Create the Category parameter 1. Click the Layout tab.

2. On the Report menu, click Report Parameters.

3. In the Report Parameters dialog box, click Add to create a new parameter.

4. Perform the following steps to add the Category parameter:

a. In the Name box, type Category.

b. Verify that the Data type is String.

c. In the Prompt box, type Category.

d. Clear the Allow blank value check box.

e. In the Available values section, select the From query option.

f. In the Dataset drop-down list, click Category.

g. In the Value field drop-down list, click Category.

Page 347: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 4: Manipulating Data Sets 5

h. In the Label field drop-down list, click Category.

i. In the Default values section, select the Non-queried option.

j. In the Default values text box, type Components.

k. Click OK to close the Report Parameters dialog box.

Task 4: Add a filter to the table data region 1. Click inside the table data region.

2. Right-click the gray box in the upper left corner of the table to select the table, and then click Properties.

3. In the Table Properties dialog box, click the Filters tab.

4. Click the first Expression cell, and then in the Expression list, click =Fields!Category.Value.

5. In the Operator list, verify that = appears.

6. In the Value list, click <Expression>.

7. In the Edit Expression dialog box, in the Fields pane, click Parameters, and then in the Parameters pane, double-click Category to add it to the Expression pane.

8. Verify that the resulting expression is as follows.

= Parameters!Category.Value

9. Click OK to close the Edit Expression dialog box, and then click OK again to close the Table Properties dialog box.

Task 5: Remove the Category group page break 1. Click inside the table data region.

2. Right-click the Category Footer row icon to select the row, and then select Edit Group.

3. Clear the Page break at end check box, and then click OK.

4. On the File menu, click Save All.

5. Click the Preview tab. Notice the Category parameter defaults to the Components category.

6. In the Category list, select Bikes, and then click View Report. Verify that the report shows sales for the Bikes category.

Task 6: Add the Category to the report header 1. Click the Layout tab.

Page 348: 2793A-ENU_TrainerWorkbook

6 Lab Answer Key for Module 4: Manipulating Data Sets

2. From the toolbox, drag a text box into the space above the graphic. Resize the text box to match the =First(Fields!Month.Value, "DataDetail") text box.

3. Right-click the new text box, and then click Expression.

4. In the Fields pane, click Parameters, and then in the Parameters pane, double-click Category to add it to the Expression pane.

5. Verify that the resulting expression is as follows.

= Parameters!Category.Value

6. Click OK to close the Edit Expression dialog box.

7. On the File menu, click Save All.

8. Click the Preview tab. Notice that the current value of the Category parameter is displayed above the graphic.

9. In the Month list, click Mar. In the Category list, click Bikes, and then click View Report. Verify that the report is updated to display sales of bikes in March.

10. On the File menu, click Close Project.

Page 349: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 4: Manipulating Data Sets 7

Exercise 3: Creating Dynamic Parameter Lists Task 1: Open the Dynamic Parameters solution

1. If Business Intelligence Development Studio is not already open, click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise03 folder, click Dynamic Parameters.sln, and then click Open.

4. In Solution Explorer, under Dynamic Parameters, double-click Product Details.rdl.

5. Click the Preview tab. Notice that the SubCategory parameter is used to restrict data in the report. The default value for the SubCategory parameter is Mountain Bikes.

Task 2: Add a data set for the Category parameter 1. Click the Data tab.

2. In the Datasets list, click <New Dataset…>.

3. In the Datasets dialog box, on the Query tab, in the Name text box, type Category.

4. In the Data source list, verify that the data source is DataSet1, and then click OK.

5. Click the Generic Query Designer button.

6. Click the Add Table button.

7. In the Add Table dialog box, click ProductCategory (Production), click Add, and then click Close.

8. In the ProductCategory (Production) table, select the following check boxes:

• ProductCategoryID

• Name

9. In the SQL pane, verify that the query is as follows.

SELECT ProductCategoryID, Name FROM Production.ProductCategory

10. Click the Verify SQL button to verify that the query is valid, and then click OK.

Task 3: Modify the SubCategory data set query 1. In the Datasets list, click SubCategory.

2. In the SQL pane, add the following WHERE statement to the end of the statement.

WHERE (ProductCategoryID = @ProductCategory)

Page 350: 2793A-ENU_TrainerWorkbook

8 Lab Answer Key for Module 4: Manipulating Data Sets

The following SQL statement should be displayed in the SQL pane.

SELECT ProductSubcategoryID, ProductCategoryID, Name FROM Production.ProductSubcategory WHERE (ProductCategoryID = @ProductCategory)

Task 4: Modify the ProductDetail data set query 1. In the Datasets list, click ProductDetail.

2. In the Grid pane, scroll down to the end of the column list, click the first blank cell, and then click PS.ProductCategoryID in the list.

3. In the Filter column of the ProductCategoryID row, type = @ProductCategory.

4. On the File menu, click Save All.

Task 5: Edit the ProductCategory parameter 1. Click the Layout tab.

2. On the Report menu, click Report Parameters. Notice that the ProductCategory parameter has been created automatically.

3. Perform the following steps to edit the ProductCategory parameter:

a. In the Parameters pane, click the ProductCategory parameter.

b. Click the up arrow button to move ProductCategory above SubCategory.

c. In the Available values section, select the From query option.

d. In the Datasets list, click Category.

e. In the Value field list, click ProductCategoryID.

f. In the Label field list, click Name.

g. In the Default values section, select the Non-queried option. A text box appears.

h. In the Default values text box, type 1.

4. Click OK to close the Report Parameters dialog box.

Task 6: Set the title of the report 1. On the Layout tab, right-click the text box that contains the text

=Globals!ReportName, and then click Expression.

2. In the Edit Expression dialog box, edit the expression as follows, and then click OK.

=Globals!ReportName + " for " & Parameters!ProductCategory.Label

3. On the File menu, click Save All.

Page 351: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 4: Manipulating Data Sets 9

4. Click the Preview tab, and then in the ProductCategory list, click Clothing. Notice that the SubCategory parameter is a dynamic parameter list dependent on the ProductCategory parameter.

5. In the SubCategory list, click Shorts, and then click View Report. Verify that the report displays product details for shorts.

6. On the File menu, click Close Project.

Page 352: 2793A-ENU_TrainerWorkbook

10 Lab Answer Key for Module 4: Manipulating Data Sets

Exercise 4: Using Parameters with a Stored Procedure Task 1: Set up the lab environment

1. Click Start, and then click My Computer.

2. Browse to the D:\Labfiles\Starter\Exercise04 folder, and then double-click runScripts.bat. The script executes in a console window. Wait for the console window to close before proceeding to the next step

3. Close the folder window.

Task 2: Open the Stored Procedure solution 1. If Business Intelligence Development Studio is not already open, click Start, point to

All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise04 folder, click Stored Procedure.sln, and then click Open.

4. In Solution Explorer, expand the Stored Procedure project, expand Reports, and then double-click Actual Vs Quota.rdl.

Task 3: Create a stored procedure data set 1. Click the Data tab.

2. In the Datasets list, click <New Dataset…>.

3. In the Datasets dialog box, on the Query tab, type Detail in the Name text box.

4. In the Data source list, ensure that AdventureWorksDW (shared) is selected.

5. In the Command type list, click StoredProcedure and then click OK.

6. In the Stored procedure list, click sp_ActualVsQuota, and then click the Run button to open the Define Query Parameters dialog box.

7. In the @CalendarYear Parameter Value text box, type 2003.

8. In the @Group Parameter Value text box, type Europe and then click OK.

9. On the File menu, click Save All.

Task 4: Edit report parameters 1. Click the Layout tab.

2. On the Report menu, click Report Parameters.

3. Perform the following steps to edit the CalendarYear parameter:

Page 353: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 4: Manipulating Data Sets 11

a. In the Parameters pane, click the CalendarYear parameter.

b. In the Available values section, ensure Non-queried is selected.

c. In the Default values section, select the Non-queried option.

d. In the Default values text box, type 2003.

4. Perform the following steps to edit the Group parameter:

a. In the Parameters pane, click the Group parameter.

b. In the Available values section, ensure Non-queried is selected.

c. In the Default values section, select the Non-queried option.

d. In the Default values text box, type North America.

5. Click OK to close the Report Parameters dialog box.

Task 5: Save and preview the report 1. On the File menu, click Save All.

2. Click the Preview tab.

3. In the Group parameter text box, type Europe, and then click View Report. Verify that the report updates to show sales performance in Europe.

4. On the File menu, click Close Project.

Page 354: 2793A-ENU_TrainerWorkbook

12 Lab Answer Key for Module 4: Manipulating Data Sets

If Time Permits: Displaying All Categories in a Parameter List Task 1: Open the All Items solution

1. If Business Intelligence Development Studio is not already open, click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise05 folder, click All Items.sln, and then click Open.

4. In Solution Explorer, expand the All Items project, expand Reports, and then double-click All Items Product Profitability.rdl.

5. Click the Preview tab. Notice that the report contains the Category parameter, which has a default value of Accessories and a list from which you can select.

6. In the Category parameter list, click Bikes, and then click View Report. Notice that there is no way to display all categories in the same report.

Task 2: Add all categories to the Category data set 1. Click the Data tab.

2. In the Datasets list, click Category.

3. In the SQL pane, add the following code above the ORDER BY clause

UNION SELECT -1, 'All Categories'

4. Click the background of the Report Designer pane.

You should have the following SQL statement in the SQL pane.

SELECT DISTINCT ProductCategoryKey AS CategoryKey, EnglishProductCategoryName AS Category FROM DimProductCategory UNION SELECT -1 AS Expr1, 'All Categories' AS Expr2 ORDER BY Category

5. Click the Run button to see the results of the query. Notice that the All Categories entry has been added to the query with a key value of -1.

6. On the File menu, click Save All.

Task 3: Update the DataDetail data set query 1. In the Datasets list, click DataDetail.

2. In the Grid pane, in the Filter column of the CategoryKey row, at the end of the = @Category statement, type OR @Category = -1 and then press ENTER.

The following SQL statement should be displayed in the SQL pane

Page 355: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 4: Manipulating Data Sets 13

SELECT Product, SubCategory, CategoryKey, Category, CostAmount, SalesAmount, OrderQuantity, Month, MonthNumberOfYear, Year FROM vProductProfitability WHERE (Year = 2003) AND (MonthNumberOfYear IN (1, 2, 3)) AND (CategoryKey = @Category OR @Category = - 1)

Note: Make sure that you are consistent with the capitalization of @Category.

3. On the File menu, click Save All.

4. Click the Preview tab.

5. In the Category parameter list, click All Categories, click View Report, and then verify that all categories are displayed in the report.

6. On the File menu, click Close Project.

Page 356: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 5: Using Report Models

Table of Contents Lab: Working with Report Models 1

Exercise 1: Creating a Report Model 1 Exercise 2: Using Report Builder to Create a Report 4

Page 357: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 5: Using Report Models 1

Lab: Working with Report Models Exercise 1: Creating a Report Model

Task 1: Create a Report Model project 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and click

SQL Server Business Intelligence Development Studio.

2. On the File menu, point to New, and then click Project.

3. In the Templates list, click Report Model Project.

4. In the Name box, type AdventureWorks Report Model.

5. In the Location box, type D:\Labfiles\Starter\Exercise1, and then click OK.

Task 2: Create a Data Source 1. In Solution Explorer, right-click Data Sources, and then click Add New Data

Source.

2. On the Welcome to the Data Source Wizard page, click Next.

3. On the Select how to define the connection page, verify that Create a data source based on an existing or new connection is selected, and then click New.

4. In the Connection Manager dialog box, in the Server name text box, type MIAMI.

5. Ensure that the Use Windows Authentication is selected.

6. In the Select or enter a database name list box, click AdventureWorks.

7. To verify that the connection works, click Test Connection, and then click OK.

8. Click OK to close the Connection Manager dialog box, and then click Next.

9. On the Completing the Wizard page, ensure that the Data source name is set to Adventure Works, and then click Finish.

Note: To edit the properties of an existing data source, double-click the data source in the Data Sources folder to display the data source properties in Data Source Designer.

Task 3: Create a Data Source View 1. In Solution Explorer, right-click Data Source Views, and then click Add New Data

Source View.

2. On the Welcome to the Data Source View Wizard page, click Next.

3. On the Select a Data Source page, in the Relational data sources pane, verify that the Adventure Works data source is selected, and then click Next.

Page 358: 2793A-ENU_TrainerWorkbook

2 Lab Answer Key for Module 5: Using Report Models

4. On the Select Tables and Views page, in the Available objects list, expand the Name column header so that you can see the table names.

5. In the Available objects list, click the following objects while holding the CTRL key:

• Person.Contact

• Sales.Customer

• Sales.Individual

• Sales.SalesOrderHeader

Note: If the object names are partially obscured, stretch the Data Source View Wizard window.

6. Click > to add the object to the Included objects list, and then click Next.

7. On the Completing the Wizard page, in the Name text box, type Customer Sales, and then click Finish.

Task 4: Create a Report Model 1. In Solution Explorer, right-click Report Models, and then click Add New Report

Model.

2. On the Welcome to the Report Model Wizard page, click Next.

3. On the Select Data Source View page, in the Available data source views list, verify that Customer Sales.dsv is selected, and then click Next.

4. On the Select report model generation rules page, view the default rules, and then click Next.

5. On the Collect Model Statistics page, ensure that Update model statistics before generating is selected, and then click Next.

6. On the Completing the Wizard page, verify that the Name of the report model is Customer Sales, and then click Run.

7. When the report model has been generated, click Finish.

8. If you are prompted to reload the Customer Sales.dsv file, click Yes to All.

9. In the Model tree, click Sales Order Header.

10. In the Properties window, in the Name text box, type Sales Order, and then in the CollectionName text box, type Sales Orders.

11. In the Attributes pane, right-click #Sales Order Headers, click Rename, type #Sales Orders, and then press ENTER.

12. On the File menu, click Save All.

Page 359: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 5: Using Report Models 3

Task 5: Publish the Report Model to a report server 1. In Solution Explorer, right-click the AdventureWorks Report Model project, and

then click Properties.

2. In the AdventureWorks Report Model Property Pages dialog box, change the value of the TargetServerURL property to http://miami/ReportServer, and then click OK.

3. In Solution Explorer, right-click the AdventureWorks Report Model project, click Deploy, and then wait for deployment to complete.

4. Close Business Intelligence Development Studio.

5. On the Start menu, point to All Programs, and then click Internet Explorer.

6. In the Address text box, type http://miami/reports, and then press ENTER.

7. Click the Models folder. Notice that Customer Sales model has been deployed to the Reports Server.

Page 360: 2793A-ENU_TrainerWorkbook

4 Lab Answer Key for Module 5: Using Report Models

Exercise 2: Using Report Builder to Create a Report Task 1: Creating a tabular report

1. Using Microsoft® Internet Explorer®, browse to http://miami/reports.

2. Click the Report Builder button.

3. In the Application Run – Security Warning dialog box, click Run. There may be a short delay while the Report Builder application is downloaded and run on your machine.

4. In the Getting Started pane in Report Builder, in the list of data sources, ensure that Customer Sales is selected.

5. In the Report Layout section, ensure Table (columnar) is selected, and then click OK.

Task 2: Add fields and entities to the report 1. In the Explorer pane, ensure that the Contact entity in the Entities list is selected.

2. In the Fields list, drag the Last Name attribute to the Drag and drop column fields area in the design area.

3. Click the Last Name text box, and then replace the text with Name.

4. Right-click the cell directly below the Name text box, and then click Edit Formula.

5. In the Formula for each Contact text box, append the text & ", " & after Last Name, and then drag the First Name field from the Fields list and drop it at the end of the expression so that the expression matches the following text. Then, click OK.

Last Name & ", " & First Name

6. Resize the Name text box to a width of approximately 1.5 inches (4 cm).

7. In the Entities list, click Sales Orders.

8. In the Fields list, drag the #Sales Orders attribute to the table region, to the right of the Name column.

9. In the Fields list, drag the Total Total Due attribute to the table region, to the right of the #Sales Orders column.

10. Click the Total Total Due text box, and then replace the text with Total Value.

11. Click the two table cells beneath the Total Value text box while holding the SHIFT key, right-click in the selected region, and then click Format.

12. In the Format dialog, in the Format list, click $1,234.56, and then click OK.

13. Stretch the Total Value text box to a width of approximately 1.25 inches (3.5 cm).

Page 361: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 5: Using Report Models 5

Task 3: Define the sort order 1. Click the Sort and Group button.

2. In the Sort by list, click Total Value, and then select the Descending option.

3. In the upper Then by list, click Name, and then click OK.

Task 4: Define the report filter 1. Click the Filter button.

2. In the Entities list, click Sales Orders.

3. From the Fields list, drag Order Date to the filter area.

4. Click equals, and then click From…To.

5. In the from box, type 10/1/2003.

6. In the to box, type 12/31/2003.

7. In the Entities list, click Customer.

8. From the Fields list, drag Customer Type to the filter area.

9. In the Customer Type criteria list, click I, and then click OK.

Task 5: Format the report 1. In the design area, click Click to add title, and then click the text box again to edit

the title.

2. Type Customer Sales, and then press ENTER.

3. On the Format menu, click Fill.

4. In the Color palette, click Cornflower.

5. On the Font tab, in the Color palette, click White, and then click OK.

6. On the Insert menu, click Filter Description.

7. Drag the text box containing the filter description and place it directly beneath the Customer Sales text box.

8. Stretch the filter text box to the same width as the Customer Sales text box.

Task 6: Run the report 1. Click the Run Report button. Notice that the report is ordered by Total value, with

totals shown at the end of the report. Notice that the filtering expression is shown at the beginning and end of the report.

2. Click Design Report.

Page 362: 2793A-ENU_TrainerWorkbook

6 Lab Answer Key for Module 5: Using Report Models

Task 7: Save the report to the report server

1. On the File menu, click Save.

2. In the Save As Report dialog box, ensure that Report Server Home is selected in the Look in list.

3. In the Name box, type Customer Sales, and then click Save.

4. Close Report Builder.

Task 8: View the report 1. Using Internet Explorer, browse to the http://miami/reports. If this page is already

open, click the browser’s Refresh button.

2. On the Home page, click Customer Sales. The report is displayed.

3. Click Vazquez, Larry. Notice that Contact entity from the report model is shown.

4. Close Internet Explorer.

Page 363: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 6: Publishing and Executing Reports

Table of Contents Lab: Publishing and Executing Reports 1

Exercise 1: Publishing Reports 1 Exercise 2: Executing a Report On Demand 4 Exercise 3: Configuring and Viewing a

Cached Report 5 Exercise 4: Configuring and Viewing a

Snapshot Report 7

Page 364: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 6: Publishing and Executing Reports 1

Lab: Publishing and Executing Reports Exercise 1: Publishing Reports

Task 1: Set up the lab environment 1. Click Start, and then click My Computer.

2. Browse to the D:\Labfiles\Starter\Exercise01 folder, and then double-click runScripts.bat. The script executes in a console window. Wait for the console window to close before proceeding to the next step.

3. Close the folder window.

Task 2: Open the Adventure Works solution 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then

click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, browse to the D:\Labfiles\Starter\Exercise01\AdventureWorks folder, click AdventureWorks.sln, and then click Open.

4. In Solution Explorer, browse the three projects that make up the Adventure Works solution and note the following:

• The Product Sales project has three reports that use two shared data sources.

• The Territory Sales project has three reports that use report-specific data sources.

• The Reseller Sales project has three reports that use report-specific data sources.

Tip: If the Solution Explorer pane is not visible, on the View menu, click Solution Explorer.

Task 3: Deploy the Adventure Works solution 1. In Solution Explorer, right-click the Product Sales project, and then click Properties.

In the Product Sales Property Pages dialog box, under Deployment, in the TargetServerURL text box, type http://miami/ReportServer, and then click OK.

2. In Solution Explorer, right-click the AdventureWorks solution, and then click Deploy Solution.

3. In the Output window, confirm that all three projects were successfully deployed without warnings.

4. Keep Business Intelligence Development Studio open.

Page 365: 2793A-ENU_TrainerWorkbook

2 Lab Answer Key for Module 6: Publishing and Executing Reports

Task 4: Browse the published reports 1. Open Microsoft® Internet Explorer® and browse to Report Manager at

http://miami/reports. Notice that there is one new folder for each project in the Adventure Works solution.

2. Click the Product Sales folder link. Notice that the Product Sales folder contains two data sources and three reports.

3. Click the Product Profitability report link and browse the report.

4. Close Internet Explorer.

Task 5: Update the Product Profitability report 1. Return to Business Intelligence Development Studio. In Solution Explorer, double-

click the Product Profitability.rdl report to open the report in the Report Designer.

2. In the Toolbox, click Textbox. In the Page Footer, create a text box next to the existing Company Confidential text box. Resize the new text box to the right edge of the page.

Tip: By default, the Toolbox is located on the left side of the screen. If the Toolbox is not visible, on the View menu, click Toolbox.

3. Click inside the new text box and type the following:

= Globals!ExecutionTime

4. Select the text box, and on the Report Formatting toolbar, click the Italic button, and then click the Align Right button.

5. Click the Preview tab, and ensure that the page footer contains the current date and time.

6. In Solution Explorer, right-click the Product Profitability report, and then click Deploy.

7. In the Output window, scroll up to view the Product Profitability report deployment information. Even though the build and deploy succeeded, notice the warnings that the data source could not be deployed because it already exists and the OverwriteDataSources property is not specified.

8. To modify the OverwriteDataSources property, in Solution Explorer, right-click the Product Sales project, and then click Properties.

9. In the Product Sales Property Pages dialog box, under Deployment, change the OverwriteDataSources property to True, and then click OK.

10. In Solution Explorer, right-click the Product Profitability report, and then click Deploy. Notice that the deployment warnings are not displayed this time.

Page 366: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 6: Publishing and Executing Reports 3

11. Close Business Intelligence Development Studio.

Task 6: Browse the updated Product Profitability report 1. Open Internet Explorer and browse to Report Manager at http://miami/reports.

2. Click the Product Sales folder link, and then click the Product Profitability report link and browse the report.

3. Keep Report Manager open.

Page 367: 2793A-ENU_TrainerWorkbook

4 Lab Answer Key for Module 6: Publishing and Executing Reports

Exercise 2: Executing a Report On Demand Task 1: Configure the Order Details report for on-demand execution

1. In Report Manager, click the Home link.

2. Click the Reseller Sales folder link, and then click Order Details. Notice that the Order Details report requires a start date, an end date, and a reseller to execute.

3. Click the Properties tab, and then click Data Sources on the left side of the screen. Notice that the custom Adventure Works data source is using Microsoft Windows® integrated security. This means that the current Windows account is used to connect to the Microsoft SQL Server™ database.

4. Under Connect using, select the Credentials supplied by the user running the report option.

5. Select the Use as Windows credentials when connecting to the data source check box.

6. Click Apply.

7. On the left side of the screen, click the Execution link. Notice that the Order Details report is set up to always run with the most recent data. Execution on demand is the default execution setting.

Task 2: View the Order Details report 1. Click the View tab.

2. In the Log In Name text box, type MIAMI\Student.

3. In the Password text box, type Pa$$w0rd.

4. Click the View Report button. You should now be able to browse the report and select a value from the report parameter lists.

5. Keep Report Manager open. You will use it in the next exercise.

Page 368: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 6: Publishing and Executing Reports 5

Exercise 3: Configuring and Viewing a Cached Report Task 1: Configure the Product Sales YTD report for cached execution

1. In Report Manager, click the Home link.

2. Click the Product Sales folder link. On the right side of the screen, click Show Details to view the details of each of the links.

3. Under the Edit column header, click the Properties button next to the Product Sales YTD report.

4. On the left side of the screen, click the Execution link.

5. Click Cache a temporary copy of the report. Expire copy of report after a number of minutes, leave the default value of 30 minutes, and then click Apply. Notice the error message that appears to the right of the minutes box, informing you that the credentials used to run this report are not stored. Because of this, the cache configuration has failed.

6. On the left side of the screen, click the Data Sources link. Notice that /Product Sales/AdventureWorksDW is the data source used by this report. You cannot update the login credentials here because this data source is shared.

7. On the upper left side of the screen, click the Product Sales link.

8. Click the AdventureWorksDW data source link.

9. Under Connect using, select Credentials stored securely in the report server.

10. In the User name text box, type MIAMI\Student.

11. In the Password text box, type Pa$$w0rd.

12. Select the Use as Windows credentials when connecting to the data source check box.

13. Ensure that the Impersonate the authenticated user after a connection has been made to the data source check box is not selected.

14. Click Apply.

Note: By storing credentials, you are indicating that the report should use the MIAMI\Student account to retrieve data for all users browsing the report. Because this is a shared data source, all reports that use the AdventureWorksDW data source will run using these stored credentials. If you want to alter this behavior, you can update these reports to use custom data sources.

15. Now that you have configured the necessary database prerequisites, enable the report for caching by repeating steps 1 to 5. Notice that there is no error message and that your report is now configured for instance caching.

Page 369: 2793A-ENU_TrainerWorkbook

6 Lab Answer Key for Module 6: Publishing and Executing Reports

16. Click the View tab. By viewing the report, you have created a cached instance that will expire in 30 minutes.

Task 2: Expire copies of the Product Sales YTD report on a schedule 1. Click the Properties tab.

2. If the execution properties are not displayed, click the Execution link.

3. Click Cache a temporary copy of the report. Expire copy of report on the following schedule, and then click Configure.

4. In the Daily Schedule area, click On the following days and note that every day of the week is selected by default.

5. In the Start time text box, type 11, select the PM option, and then click OK.

6. On the Execution page, click Apply. In this scenario, you chose a report-specific schedule to expire the cache at the end of each day. Note that if you have several Reporting Services operations that execute at the same time, such as at the end of each day, you should consider using a shared schedule instead of a report-specific schedule.

7. Click the View tab and browse the report. By viewing the report, you have created a cached instance that will expire at 11:00 P.M. this evening.

Note: You can confirm this scheduled action by opening SQL Server Management Studio, connecting to the database engine on MIAMI, and viewing the list of jobs in the SQL Server Agent.

Page 370: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 6: Publishing and Executing Reports 7

Exercise 4: Configuring and Viewing a Snapshot Report Task 1: Change the Reseller Sales report to use AdventureWorksDW

1. In Report Manager, click the Home link.

2. Click the Reseller Sales folder link, and then click the Show Details button.

3. Under the Edit column header, click the Properties button next to the Reseller Sales report.

4. Click the Data Sources link. To create a snapshot for this report, you must store its data source login credentials. Instead of changing the custom data source settings, you will change the report to use the Product Sales\AdventureWorksDW shared data source, for which credentials are already stored.

5. Click A shared data source, and then click Browse.

6. Expand the Product Sales folder, click AdventureWorksDW, click OK, and then click Apply.

Task 2: Schedule a snapshot to run at the beginning of the month 1. In Report Manager, click the Site Settings link.

2. At the bottom of the screen, under Other, click the Manage shared schedules link.

3. Click the New Schedule button.

4. In the Schedule Name text box, type Beginning of Month.

5. Under Scheduled Details, click Month.

6. Under Monthly Schedule, configure the following:

• Select the On calendar day(s) option, and then type 1 to execute on the first day of the month.

• In the Start Time text box, type 05:00, and then select the A.M. option.

7. Click OK.

8. In Report Manager, click the Home link.

9. Click the Reseller Sales folder link, and then click the Show Details button.

10. Under the Edit column header, click the Properties button next to the Reseller Sales report.

11. On the left side of the screen, click the Execution link.

12. Select the Render this report from a report execution snapshot option, and then select the Use the following schedule to create report execution snapshots check box.

Page 371: 2793A-ENU_TrainerWorkbook

8 Lab Answer Key for Module 6: Publishing and Executing Reports

13. Select the Shared schedule option, and ensure that the list is set to Beginning of Month.

14. Clear the Create a report snapshot when you click the Apply button on this page check box, and then click Apply. The report now will not be available until it executes for the first time on the first day of the next month.

Task 3: Store Reseller Sales snapshots in report history 1. On the left side of the screen, click the History link.

2. Select the Store all report execution snapshots in history check box.

3. Under Select the number of snapshots to keep, select Limit the copies of report history, and then type 12 in the text box.

4. Click Apply, and when asked to confirm, click OK.

Task 4: View the Reseller Sales report and report history 1. Click the View tab and verify that the following error message is displayed.

The selected report is not ready for viewing. The report is still being rendered or a report snapshot is not available. (rsReportNotReady)

A report snapshot will only be available after a scheduled snapshot has been run.

2. Click the Properties tab, and on the left side of the screen, click the Execution link.

3. Select the Create a report snapshot when you click the Apply button on this page check box, and then click Apply. A report snapshot is created.

4. Click the View tab and verify that you can view the report snapshot.

5. Click the History tab and verify that a snapshot has been created and is now stored in history.

6. Close Report Manager.

Page 372: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 7: Using Subscriptions to Distribute Reports

Table of Contents Lab: Implementing Subscriptions 1

Exercise 1: Creating a Standard Subscription 1 Exercise 2: Creating a Data-Driven Subscription 4

Page 373: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 7: Using Subscriptions to Distribute Reports 1

Lab: Implementing Subscriptions Exercise 1: Creating a Standard Subscription

Task 1: Set up the lab environment 1. Click Start, and then click My Computer.

2. Browse to the D:\Labfiles\Starter\Exercise01 folder, and then double-click runScripts.bat. The script executes in a console window. Wait for the console window to close before proceeding to the next step.

3. Close the folder window.

Task 2: Open and deploy the AdventureWorks solution 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then

click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise01\AdventureWorks folder, click AdventureWorks.sln, and then click Open.

4. In Solution Explorer, right-click the AdventureWorks solution, and then click Deploy Solution.

Tip: If the Solution Explorer pane is not visible, on the View menu, click Solution Explorer.

5. In the Output window, confirm that all three projects were successfully deployed without warnings.

6. Close Business Intelligence Development Studio.

Task 3: Configure a shared data source 1. Click Start, point to All Programs, and then click Internet Explorer.

2. In the Address box, type http://miami/reports, and then press ENTER.

3. Click the Product Sales.

4. Click the AdventureWorksDW data source link.

5. Under Connect using, select Credentials stored securely in the report server.

6. In the User name box, type MIAMI\Student.

7. In the Password box, type Pa$$w0rd.

Page 374: 2793A-ENU_TrainerWorkbook

2 Lab Answer Key for Module 7: Using Subscriptions to Distribute Reports

8. Select the Use as Windows credentials when connecting to the data source check box.

9. Ensure that the Impersonate the authenticated user after a connection has been made to the data source check box is not selected.

10. Click Apply.

Note: By storing credentials, you are indicating that the report should use the MIAMI\Student account to retrieve data for all users browsing the report. Because this is a shared data source, all reports that use the AdventureWorksDW data source will run using these stored credentials. If you want to alter this behavior, you can update these reports to use custom data sources.

Task 4: Create a standard subscription 1. On the upper left side of the screen, click the Product Sales link.

2. Click Show Details, and then click the Properties icon next to the Product Profitability report.

3. Click the Subscriptions tab, and then click New Subscription to view the subscription options.

4. In the Delivered by list, click Report Server File Share.

5. Verify that the Add a file extension when the file is created check box is selected.

6. In the Path text box, type \\MIAMI\Reports.

7. In the Render Format list, select Excel.

8. Under Overwrite options, select the Increment file names as newer versions are added option.

Note: Incrementing file names adds a number to the file suffix. Each time the subscription executes, the number increments by one.

9. In the Subscription Processing Options section, under Run the subscription, ensure that the When the scheduled report run is complete option is selected, and then click Select Schedule.

10. Select the Once option, and then set the Start time to be three minutes later than the current time, and then click OK. If prompted to use AutoComplete, click Yes.

11. Under Report Parameter Values, for the Year and Month parameters, select the Use Default check box.

Page 375: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 7: Using Subscriptions to Distribute Reports 3

12. For the Category parameter, select All Product.

13. Under Credentials used to access the file share, in the User Name text box, type MIAMI\Student.

14. In the Password text box, type Pa$$w0rd.

15. Click OK.

Task 5: View the standard subscription output 1. Right-click Start, and then click Explore to open Windows Explorer.

2. In the Address bar, type \\MIAMI\Reports.

Note: Shortly after the execution time that you specified above, the file should appear. This might take several minutes.

3. Double-click Product Profitability.xls to open it in Microsoft® Office Excel®.

4. View the Excel output, and then on the File menu, click Exit.

5. If you are prompted to save the file, click No.

6. Close Microsoft Windows® Explorer.

Page 376: 2793A-ENU_TrainerWorkbook

4 Lab Answer Key for Module 7: Using Subscriptions to Distribute Reports

Exercise 2: Creating a Data-Driven Subscription Task 1: Change the Actual Vs Quota report to use a shared data source

1. In Report Manager, click the Home link.

2. Click the Territory Sales folder link, and then click the Actual Vs Quota report.

Note: The report requires two parameters to execute: CalendarYear and Group. When you build the subscription later in this exercise, it is important that the correct Group parameter value is linked to the corresponding regional Sales Director. This information is stored in a database table for each sales director, along with other report delivery information.

3. Click the Properties tab, and then click the Data Sources link.

4. Click the A shared data source option, and then click Browse.

5. Expand the Product Sales folder, and then click AdventureWorksDW.

6. Click OK, and then click Apply.

Task 2: View the SubscriptionGroupDirector table 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, click

SQL Server Management Studio.

2. When prompted, ensure that Database Engine is selected in the Server type box, MIAMI is selected in the Server name box, and Windows Authentication is selected in the Authentication box. Then click Connect.

3. In Object Explorer, expand Databases, expand AdventureWorksDW, and then click Tables.

4. In the table list, right-click the SubscriptionGroupDirector table, and then click Open Table. Notice that the table contains parameters for three report subscriptions.

5. Close Microsoft SQL Server™ Management Studio.

Task 3: Create a data-driven subscription 1. In Report Manager, click the Subscriptions tab for the Actual Vs Quota report, and

then click New Data-driven Subscription.

2. In the Description text box, type Actual Vs Quota Subscription.

3. In the Specify how recipients are notified list, click Report Server E-mail.

4. Select Specify a shared data source, and then click Next.

5. Expand the Product Sales folder, click AdventureWorksDW, and then click Next.

6. In the query box, type SELECT * FROM dbo.SubscriptionGroupDirector.

Page 377: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 7: Using Subscriptions to Distribute Reports 5

7. Click Validate. Towards the bottom of the page, verify that a Query validated successfully message is displayed, and then click Next.

8. Configure the properties by using the following table.

Property Option Value

To Get the value from the database To

Cc No value None

Bcc No value None

Reply-To Specify a static value [email protected]

Include Report Get the value from the database IncludeReport

Render Format Get the value from the database RenderFormat

Priority Specify a static value Normal

Subject Specify a static value @ReportName was executed at @ExecutionTime

Comment No value None

Include Link Get the value from the database IncludeLink

9. Click Next.

10. For the CalendarYear parameter, select the Use Default check box.

11. Under Group, click Get the value from the database, and in the list, click GroupParameter, and then click Next.

12. Select On a schedule created for this subscription, and then click Next.

13. Under Schedule details, click Once. Set the start time to execute two minutes later than the current time.

14. Click Finish.

Task 4: View the subscription notifications 1. Wait until the time you scheduled the subscription to run, then click Start, point to

All Programs, and click Outlook Express.

2. If the inbox is empty, wait for a short time, and then click the Send/Recv button.

3. On the Tools menu, click Options. Then on the Read tab, clear the Read all messages in plain text checkbox and click OK.

4. Read each e-mail message, and view any attachments.

5. Close Microsoft Outlook® Express.

Page 378: 2793A-ENU_TrainerWorkbook
Page 379: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 8: Administrating Reporting Services

Table of Contents Lab: Administrating Reporting Services 1

Exercise 1: Using Reporting Services Configuration Manager 1

Exercise 2: Securing a Reporting Services Site 2 Exercise 3: Securing Items 5

Page 380: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 8: Administrating Reporting Services 1

Lab: Administrating Reporting Services Exercise 1: Using Reporting Services Configuration Manager

Task 1: View Reporting Services settings 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, point to

Configuration Tools, and then click Reporting Services Configuration.

2. When prompted, click Connect to connect to the MSSQLSERVER instance on MIAMI.

3. View the Server Status page, and notice that the service is running.

4. In the navigation pane on the left, notice that all of the items have been configured with the exception of the Encryption Keys item, which requires optional configuration.

5. Click each item in the navigation pane in turn, and review the settings in the corresponding configuration pages.

Task 2: Back up the Reporting Services encryption keys 1. In the navigation pane, click Encryption Keys, and then click Backup.

2. In the Encryption Key Information dialog box, in the Password box, type Pa$$w0rd, and then click the button to the right of the Key File box.

3. In the Save As dialog box, browse to the D:\Labfiles\Starter folder, type Keys in the File name text box, and then click Save.

4. Click OK.

5. Close Reporting Services Configuration Manager.

Page 381: 2793A-ENU_TrainerWorkbook

2 Lab Answer Key for Module 8: Administrating Reporting Services

Exercise 2: Securing a Reporting Services Site Task 1: Set up the lab environment

1. Click Start, and then click My Computer.

2. Browse to the D:\Labfiles\Starter folder, and then double-click runScripts.bat. The script executes in a console window. Wait for the console window to close before proceeding to the next step.

3. Close the folder window.

Task 2: Open and deploy the Sales Reports solution 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then

click SQL Server Business Intelligence Development Studio.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, browse to the D:\Labfiles\Starter folder, click Sales Reports.sln, and then click Open.

4. In Solution Explorer, right-click the Sales Reports solution, and then click Deploy.

Tip: If the Solution Explorer pane is not visible, on the View menu, click Solution Explorer.

5. In the Output window, verify that all objects in the solution were successfully deployed without warnings.

6. Close Business Intelligence Development Studio.

Task 3: Configure the AdventureWorks Data Source 1. Open Microsoft® Internet Explorer® and browse to http://miami/reports to open

Report Manager.

2. Click the Sales Reports folder, and then click the AdventureWorks data source.

3. Under Connect using, select Credentials stored securely in the report server, type MIAMI\Student in the User name box, and then type Pa$$w0rd in the Password box.

4. Select the Use as Windows credentials when connecting to the data source check box, and then click Apply.

5. Close Internet Explorer.

Task 4: Open Report Manager as the NADirector user 1. Click Start, point to All Programs, right-click Internet Explorer, and then click

Run as.

Page 382: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 8: Administrating Reporting Services 3

2. In the Run As dialog box, select The following user, type MIAMI\NADirector in the User name box, type Pa$$w0rd in the Password box, and then click OK.

3. Navigate to http://miami/Reports. When prompted, type MIAMI\NADirector in the User name box, type Pa$$w0rd in the Password box, and then click OK. Note that the user has no permissions, and can therefore see no objects in Report Manager.

4. Close Internet Explorer.

Task 5: Create a new role 1. Open Internet Explorer, and then navigate to http://miami/Reports.

Warning: Do not use the Run As option.

2. Click Site Settings.

3. In the Security section, click Configure site-wide security.

4. Click the New Role Assignment button, and then click New Role.

5. In the Name text box, type Security Manager. In the Description text box, type Can set item and site security.

6. Select only the Manage report server security and Manage roles task check boxes.

7. Click OK.

Task 6: Assign the new role to the AWSalesDirectors group 1. In the Group or user name text box, type MIAMI\AWSalesDirectors.

2. Select only the Security Manager role check box.

3. Click OK.

4. Close Internet Explorer.

Task 7: View site settings as the NADirector user 1. Click Start, point to All Programs, right-click Internet Explorer, and then click

Run as.

2. In the Run As dialog box, click The following user, type MIAMI\NADirector in the Username box, and then type Pa$$w0rd in the Password box and click OK. Note that the NADirector user is a member of the AWSalesDirectors group.

3. Navigate to http://miami/Reports. When prompted, type MIAMI\NADirector in the User name box, type Pa$$w0rd in the Password box, and then click OK.

Page 383: 2793A-ENU_TrainerWorkbook

4 Lab Answer Key for Module 8: Administrating Reporting Services

4. Click Site Settings.

• Note that the only the Security section is available.

5. Close Internet Explorer.

Page 384: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 8: Administrating Reporting Services 5

Exercise 3: Securing Items Task 1: Assign the item permissions

1. Open Internet Explorer and navigate to http://miami/Reports.

Warning: Do not use the Run As option.

2. Click the Properties tab, and then click the New Role Assignment button.

3. In the Group or user name text box, type MIAMI\AWSalesDirectors.

4. Select only the Browser check box, and then click OK. The AWSalesDirectors group now has permission to browse all items in the Home folder.

5. Click the Contents tab, click the Samples folder link, click the Properties tab, and then on the left side of the screen, click the Security link.

6. Click Edit Item Security, and when prompted to apply different security settings from the parent, click OK.

7. Select the check box next to the MIAMI\AWSalesDirectors group, click Delete, and then click OK to confirm your action.

8. Close Internet Explorer.

Task 2: Browse reports as the NADirector user 1. Click Start, point to All Programs, right-click Internet Explorer, and then click

Run as.

2. In the Run As dialog box, click The following user, type MIAMI\NADirector in the User name box, type Pa$$w0rd in the Password box, and then click OK.

3. Navigate to http://miami/Reports. When prompted, type MIAMI\NADirector in the User name box, type Pa$$w0rd in the Password box, and then click OK. Note that the Samples folder link is not visible because the user has no permissions on the Samples folder.

4. Click the Sales Reports folder link, and then click the Company Sales report link to view the report.

5. Click the Properties tab. Note that you cannot set any properties for the report because the user only has permission to browse.

6. Close Internet Explorer.

Page 385: 2793A-ENU_TrainerWorkbook
Page 386: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 9: Programming Reporting Services

Table of Contents Lab: Programming Reporting Services 1

Exercise 1: Using URL Access to Display a Report 1

Exercise 2: Building a Reporting Services Web Service Client 4

Exercise 3: Using the Report Viewer Control 6

Page 387: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 9: Programming Reporting Services 1

Lab: Programming Reporting Services Exercise 1: Using URL Access to Display a Report

Task 1: Specify default values for a report URL 1. Click Start, point to All Programs, point to Microsoft Visual Studio 2005, and then

click Microsoft Visual Studio 2005.

2. On the File menu, point to Open, and then click Project/Solution.

3. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise01 folder, click ReportURL.sln, and then click Open.

4. In Solution Explorer, right-click Default.aspx, and then click View Designer. Notice that there is a table located at the top of the page with seven labeled rows, and a Show Report button in the eighth row. Each labeled row contains a control permitting user input.

5. In the Properties window, in the list, click ReportServerTextBox.

6. Set the Text property to http://miami/reportserver.

7. In the Properties window, in the list, click FolderTextBox.

8. Set the Text property to /Samples/AdventureWorks Sample Reports/.

9. In the Properties window, in the list, click ReportNameTextBox.

10. Set the Text property to Company Sales.

Task 2: Implement report invocation 1. Double-click the Show Report button.

2. Under the constants comment, type the following code.

Const RENDER_COMMAND As String = "&rs:Command=Render" Const TOOLBAR As String = "&rc:Toolbar=" Const ZOOM As String = "&rc:Zoom="

3. In the Button1_Click event, under the create report url comment, type the following code.

Dim url As String url = ReportServerTextBox.Text + "?" + _ FolderTextBox.Text + ReportNameTextBox.Text + _ RENDER_COMMAND

4. Under the redirect to report page comment, type the following code.

Response.Redirect(url, True)

5. On the Debug menu, click Start Debugging.

Page 388: 2793A-ENU_TrainerWorkbook

2 Lab Answer Key for Module 9: Programming Reporting Services

6. Click Show Report. The Company Sales report is displayed in Microsoft® Internet Explorer®.

7. Close Internet Explorer.

Task 3: Configure toolbar and zoom settings 1. In Microsoft Visual Studio®, click the Default.aspx tab to view the Web page in

design view.

2. Click the combo box next to the Show Toolbar label, click the smart tag, and then click Edit Items.

3. In the ListItem Collection Editor dialog box, click Add, and then in the Text property, type True.

4. Click Add, and in the Text property, type False. Then click OK.

5. Click the combo box next to the Zoom label, click the smart tag, and then click Edit Items.

6. In the ListItem Collection Editor dialog box, click Add, and then in the Text property, type 100.

7. Click Add, and then in the Text property, type 200. Then click OK.

8. Click the Default.aspx.vb tab to view the Microsoft Visual Basic® code for the Web page.

9. Under the configure toolbar and zoom comment, type the following code.

url += TOOLBAR + ToolbarDropDownList.Text + _ ZOOM + ZoomDropDownList.Text

10. On the Debug menu, click Start Debugging.

11. In the Show Toolbar list, click False, and then in the Zoom list, click 200.

12. Click the Show Report button. The Company Sales report is displayed without a toolbar at 200% magnification.

13. Close Internet Explorer.

Task 4: Add report parameters 1. In Code view, after the conditionally add parameter comment, add the following

code.

If ParameterNameTextBox.Text.Length > 0 Then url += "&" + ParameterNameTextBox.Text + "=" + ParameterValueTextBox.Text

End If

2. On the Debug menu, click Start Debugging.

3. In the Report Name text box, change the value to Employee Sales Summary.

Page 389: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 9: Programming Reporting Services 3

4. In the Parameter Name text box, type EmpID.

5. In the Parameter Value text box, type 285, and then click the Show Report button. The Employee Sales Summary report is displayed for employee 285, Jae Pak.

6. Close Internet Explorer.

7. On the File menu, click Close Project. Keep Visual Studio open – you will use it in the next exercise.

Page 390: 2793A-ENU_TrainerWorkbook

4 Lab Answer Key for Module 9: Programming Reporting Services

Exercise 2: Building a Reporting Services Web Service Client Task 1: Add a Web reference to the Report Server Web service

1. In Visual Studio, on the File menu, point to Open, and click Project/Solution.

2. In the Open Project dialog box, navigate to the D:\Labfiles\Starter\Exercise02 folder, click ReportManager.sln, and then click Open.

3. In Solution Explorer, right-click the ReportManager, and then click Add Web Reference.

4. In the URL text box, type the following URL, and then click Go: http://miami/ReportServer/ReportService2005.asmx?wsdl

5. After the Web service is located, in the Web reference name text box, change the default value (miami) to ReportService, and then click Add Reference.

Task 2: Add code to the form to retrieve server information 1. In Solution Explorer, right-click frmManage.vb, and then click View Code.

2. At the very top of the file, add an Imports statement to the ReportManager.ReportService namespace, as shown in the following code.

Imports ReportManager.ReportService

3. After the existing Inherits statement, create a class-level variable named rs that references the ReportingService2005 proxy class. Your code should appear as follows.

Private rs As New ReportingService2005

4. Locate the frmManage_Load event, and before the call to the LoadInformation method, add the following code to set the credentials.

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

5. Locate the LoadInformation method.

6. Modify the code as shown here.

Private Sub LoadInformation() 'load information into list view lstView.Items.Clear() Dim myCatalogItems As CatalogItem() myCatalogItems = rs.ListChildren("/", True) For Each cItem As CatalogItem In myCatalogItems Dim strValues(3) As String strValues(0) = cItem.Name strValues(1) = cItem.Path strValues(2) = cItem.Type.ToString()

Page 391: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 9: Programming Reporting Services 5

strValues(3) = cItem.CreatedBy lstView.Items.Add(New ListViewItem(strValues)) Next End Sub

The code creates a list of all the items on the report server. It then loops through the list and displays the information in the list view control.

Task 3: Add code to retrieve individual item information 1. Locate the DisplayCurrentInfo method.

2. Modify the code as shown here.

Private Sub DisplayCurrentInfo() Me.Cursor = Cursors.WaitCursor

'display item information in messagebox Dim item As ListViewItem = lstView.SelectedItems(0) Dim strName As String = item.SubItems(0).Text Dim strPath As String = item.SubItems(1).Text Dim properties As [Property]() properties = rs.GetProperties(strPath, Nothing) Dim sb As New System.Text.StringBuilder For Each prop As [Property] In properties sb.Append(prop.Name & ": " & prop.Value & vbCrLf) Next MessageBox.Show(sb.ToString(), _ "Properties of " & strName) Me.Cursor = Cursors.Default End Sub

The code retrieves information from the server about the item selected in the list view control. The information is then displayed in a message box.

Task 4: Test the application 1. On the Debug menu, click Start Debugging. When the form loads (this might take a

few seconds), it should display the list of all available items on the report server.

2. Select one of the reports from the list view, and then click Get Info. Examine the properties displayed in the message box before closing it.

3. Select one of the folders from the list view, and then click Get Info. Examine the properties displayed in the message box before closing it.

4. Click Close.

5. On the File menu, click Close Project. Keep Visual Studio open – you will use it in the next exercise.

Page 392: 2793A-ENU_TrainerWorkbook

6 Lab Answer Key for Module 9: Programming Reporting Services

Exercise 3: Using the Report Viewer Control Task 1: Add a Report Viewer to a Web page

1. In Visual Studio, on the File menu, point to Open, and click Project/Solution.

2. In the Open Project dialog box, browse to the D:\Labfiles\Starter\Exercise03 folder, click ReportURL.sln, and then click Open.

3. In Solution Explorer, right-click Default.aspx, and then click View Designer.

4. From the Data section of the Toolbox, drag a Report Viewer control onto the design surface under the existing table. Ignore the Report Viewer Tasks smart tag.

5. Set the Height property of the Report Viewer control to 500px, and the Width property of the Report Viewer control to 700px.

Task 2: Configure the Report Viewer control 1. In Solution Explorer, right-click Default.aspx, and then click View Code.

2. At the top of the Code Window, type the following code.

Imports Microsoft.Reporting.WebForms

3. Under the use remote processing comment, type the following code.

ReportViewer1.ProcessingMode = ProcessingMode.Remote Dim serverReport As ServerReport serverReport = ReportViewer1.ServerReport

4. Under the set the report server URL and report path comment, type the following code.

serverReport.ReportServerUrl = New Uri(ReportServerTextBox.Text) serverReport.ReportPath = FolderTextBox.Text + ReportNameTextBox.Text

5. On the Debug menu, click Start Debugging.

6. Click the Show Report button. The Company Sales report is displayed in the Report Viewer, beneath the parameter table.

7. Close Internet Explorer.

Task 3: Add report parameters 1. In Code view, underneath the conditionally add parameter comment, add the

following code.

If ParameterNameTextBox.Text.Length > 0 Then Dim parameter As New ReportParameter() parameter.Name = ParameterNameTextBox.Text parameter.Values.Add(ParameterValueTextBox.Text) 'set the report parameters for the report Dim parameters() As ReportParameter = {parameter} serverReport.SetParameters(parameters) End If

2. On the Debug menu, click Start Debugging.

Page 393: 2793A-ENU_TrainerWorkbook

Lab Answer Key for Module 9: Programming Reporting Services 7

3. In the Report Name text box, change the value to Employee Sales Summary.

4. In the Parameter Name text box, type EmpID.

5. In the Parameter Value text box, type 288, and then click the Show Report button. The Employee Sales Summary report is displayed for employee 288, Syed Abbas.

6. Close Internet Explorer.

7. Close Visual Studio.