Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Integration Services
In this chapter:
Files needed:
ISProject1.zip
ISProject2.zip
You can launch the Import and Export wizard from the Tasks entry on the shortcut
menu of any database in the Object Explorer window of SQL Server Management
Studio.
Try It!
To import some data using the Import and Export Wizard, follow these steps:
1. Launch SQL Server Management Studio and log in to your test server.
16-2
16-3
15. Select the HumanResources.Shift table and click on the Edit Mappings
button.
16. The Column Mappings dialog box lets you change the name, data type, and
other properties of the destination table columns. You can also set other options
here, such as whether to overwrite or append data when importing data to an
existing table. Click Cancel when youre done inspecting the options.
17. Click Next.
18. Check Execute Immediately and click Next.
19. Click Finish to perform the import. SQL Server will display progress as it
performs the import, as shown in Figure 16-2.
16-4
16-5
Creating a Package
The Import and Export Wizard is easy to use, but it only taps a small part of the
functionality of SSIS. To really appreciate the full power of SSIS, youll need to use
BIDS to build an SSIS package. A package is a collection of SSIS objects including:
Youll see how to build each of these components of a package in later sections of the
chapter, but first, lets fire up BIDS and create a new SSIS package.
Try It!
To create a new SSIS package, follow these steps:
1.
2.
3.
4.
5.
6.
16-6
Handles
Connecting to ADO objects such as a
Recordset.
Connecting to data sources through an
ADO.NET provider.
Connects to a cache either in memory or in a file
Connecting to an Analysis Services database or
cube.
Connecting to an Excel worksheet.
Connecting to a file or folder.
Connecting to delimited or fixed width flat files.
Connecting to an FTP data source.
Connecting to an HTTP data source.
16-7
Try It!
To add some connection managers to your package, follow these steps:
1. Right-click in the Connection Managers area of your new package and select
New OLE DB Connection.
2. Note that the configuration dialog box will show the data connections that you
created in Chapter 15; data connections are shared across Analysis Services and
Integration Services projects. Click New to create a new data connection.
3. In the Connection Manager dialog box, select the SQL Native Client provider.
4. Select your test server and provide login information.
5. Select the Chapter16 database.
6. Click OK.
7. In the Configure OLE DB Connection Manager dialog box, click OK.
8. Right-click in the Connection Managers area of your new package and select
New Flat File Connection.
9. Enter DepartmentList as the Connection Manager Name.
10. Enter C:\Departments.txt as the File Name.
11. Check the Column Names in the First Data Row checkbox. Figure 16-4 shows
the completed General page of the dialog box.
16-8
Try It!
12. Click the Advanced icon to move to the Advanced page of the dialog box.
13. Click the New button.
14. Change the Name of the new column to DepartmentName.
15. Click OK.
16. Right-click the DepartmentList Connection Manager and select Copy.
17. Right-click in the Connection Managers area and select Paste.
18. Click on the new DepartmentList 1 connection to select it.
19. Use the Properties Window to change properties of the new connection.
Change the Name property to DepartmentListBackup. Change the
ConnectionString property to C:\DepartmentsBackup.txt.
Figure 16-5 shows the SSIS package with the three Connection Managers defined.
Copyright 2009 Accelebrate, Inc.
16-9
16-10
Tasks are things that SSIS can do, such as execute SQL statements or transfer
objects from one SQL Server to another. Table 16-2 lists the available tasks.
Maintenance Plan tasks are a special group of tasks that handle jobs such as
checking database integrity and rebuilding indexes. Table 16-3 lists the
maintenance plan tasks.
The Data Flow Task is a general purpose task for ETL (extract, transform, and
load) operations on data. Theres a separate design tab for building the details
of a Data Flow Task.
Containers are objects that can hold a group of tasks. Table 16-4 lists the
available containers.
Purpose
ActiveX Script
Analysis Services Execute DDL
Analysis Services Processing
Bulk Insert
Data Mining Query
Data Profiling Task
Task
Back Up Database
Check Database Integrity
Execute SQL Server Agent Job
Execute T-SQL Statement
History Cleanup
Maintenance Cleanup
Notify Operator
Purpose
Back up an entire database to file or tape
Perform database consistency checks
Run a job
Run any T-SQL script
Clean out history tables for other maintenance
tasks
Clean up files left by other maintenance tasks
Send e-mail to SQL Server operators
16-11
Container
For Loop
Foreach Loop
Sequence
Purpose
Repeat a task a fixed number of times
Repeat a task by enumerating over a group of
objects
Group multiple tasks into a single unit for easier
management
Table 16-4: SSIS containers
Try It!
To add control flow tasks to the package youve been building, follow these steps:
1. If the Toolbox isnt visible already, hover your mouse over the Toolbox tab
until it slides out from the side of the BIDS window. Use the pushpin button in
the Toolbox title bar to keep the Toolbox visible.
2. Make sure the Control Flow tab is selected in the Package Designer.
3. Drag a File System Task from the Toolbox and drop it on the Package Designer.
4. Drag a Data Flow Task from the Toolbox and drop it on the Package Designer,
somewhere below the File System task.
5. Click on the File System Task on the Package Designer to select it.
6. Drag the green arrow from the bottom of the File System Task and drop it on
top of the Data Flow Task. This tells SSIS the order of tasks when the File
System Task succeeds.
7. Double-click the connection between the two tasks to open the Precedence
Constraint Editor.
8. Change the Value from Success to Completion, because you want the Data
Flow Task to execute whether the File System Task succeeds or not.
9. Click OK.
10. Select the File System task in the designer. Use the Properties Window to set
properties of the File System Task. Set the Source property to
DepartmentList. Set the Destination property to DepartmentListBackup.
Set the OverwriteDestinationFile property to True then click OK.
Figure 16-6 shows the completed set of control flow tasks.
16-12
As it stands, this package uses the file system task to copy the file specified by the
DepartmentList connection to the file specified by the DepartmentListBackup
connection, overwriting any target file that already exists. It then executes the data
flow task. In the next section, youll see how to configure the data flow task.
Data Flow Sources are ways that data gets into the system. Table 16-5 lists the
available data flow sources.
Data Flow Transformations let you alter and manipulate the data in various
ways. Table 16-6 lists the available data flow transformations.
Data Flow Destinations are the places that you can send the transformed data.
Table 16-7 lists the available data flow destinations.
16-13
Use
ADO NET
Excel
Flat File
OLE DB
Raw File
XML
Transformation
Aggregate
Audit
Cache Transform
Character Map
Conditional Split
Copy Column
Data Conversion
Data Mining Query
Derived Column
Export Column
Fuzzy Grouping
Fuzzy Lookup
Import Column
Lookup
Merge
Merge Join
Multicast
OLE DB Command
Percentage Sampling
Pivot
Row Count
Row Sampling
Script Component
Slowly Changing Dimension
Sort
Term Extraction
Term Lookup
Union All
Unpivot
Effect
Aggregates and groups values in a dataset
Adds audit information to a dataset
Populates a CACHE connection manager
Applies string operations to character data
Evaluates and splits up rows in a dataset
Copies a column of data
Converts data to a different datatype
Runs a data mining query
Calculates a new column from existing data
Exports data from a column to a file
Groups rows that contain similar values
Looks up values using fuzzy matching
Imports data from a file to a column
Looks up values in a reference dataset
Merges two sorted datasets
Merges data from two datasets by using a join
Creates copies of a dataset
Executes a SQL command on each row in a
dataset
Extracts a subset of rows from a dataset
Builds a pivot table from a dataset
Counts the rows of a dataset
Extracts a sample of rows from a dataset
Executes a custom script
Updates a slowly changing dimension table
Sorts data
Extracts data from a column
Looks up the frequency of a term in a column
Merges multiple datasets
Normalizes a pivot table
16-14
Use
Sends data to a .NET data provider
Sends data to an Analysis Services data mining
model
Sends data to an in-memory ADO.NET
DataReader
Processes a cube dimension
Sends data to an Excel worksheet
Sends data to a flat file
Sends data to an OLE DB database
Processes an Analysis Services partition
Sends data to a raw file
Sends data to an in-memory ADO Recordset
Sends data to a SQL Server CE database
Sends data to a SQL Server database
Table 16-7: Data Flow Destinations
Try It!
To customize the data flow task in the package youre building, follow these steps:
1. Select the Data Flow tab in the Package Designer. The single Data Flow Task in
the package will automatically be selected in the combo box.
2. Drag an OLE DB Source from the Toolbox and drop it on the Package Designer.
3. Drag a Character Map Transformation from the Toolbox and drop it on the
Package Designer.
4. Drag a Flat File Destination from the Toolbox and drop it on the Package
Designer.
5. Click on the OLE DB Source on the Package Designer to select it.
6. Drag the green arrow from the bottom of the OLE DB Source and drop it on top
of the Character Map Transformation.
7. Click on the Character Map Transformation on the Package Designer to select
it.
16-15
16-16
16-17
16-18
The data flow tasks in this package take a table from the Chapter16 database,
transform one of the columns in that table to all uppercase characters, and then write
that transformed column out to a flat file.
16-19
Try It!
To add an event handler to the package weve been building, follow these steps:
1. Open SQL Server Management Studio and connect to your test server.
2. Create a new query and select the Chapter16 database in the available
databases list on the toolbar.
3. Enter this text into a query window:
CREATE TABLE DepartmentExports(
ExportID int IDENTITY(1,1) NOT NULL,
ExportTime datetime NOT NULL
CONSTRAINT DF_DepartmentExports_ExportTime DEFAULT
(GETDATE()),
CONSTRAINT PK_DepartmentExports PRIMARY KEY CLUSTERED
(
ExportID ASC
)
)
4.
5.
6.
7.
16-20
Try It!
To store copies of the package youve developed, follow these steps.
1. Select File f Save Copy of Package.dtsx As from the BIDS menus.
2. Select SSIS Package Store as the Package Location.
3. Select the name of your test server.
4. Enter /File System/ExportDepartments as the package path.
5. Click OK.
6. Select File f Save Copy of Package.dtsx As from the BIDS menus.
7. Select SQL Server as the Package Location.
8. Select the name of your test server and fill in your authentication information.
9. Enter ExportDepartments as the package path.
10. Click OK.
Running a Package
You can run the final package from either BIDS or SQL Server Management Studio.
When youre developing a package, its convenient to run it directly from BIDS.
Copyright 2009 Accelebrate, Inc.
16-21
Try It!
To run the package that you have loaded in BIDS, follow these steps:
1. Click the Start Debugging toolbar button. SSIS will execute the package,
highlighting the steps in the package as they are completed. You can select any
tab to watch whats going on. For example, if you select the Control Flow tab,
youll see tasks highlighted, as shown in Figure 16-11.
16-22
2. When the package finishes executing, click the hyperlink underneath the
Connection Managers pane to stop the debugger.
3. Click the Execution Results tab to see detailed information on the package, as
shown in Figure 16-12.
16-23
All of the events you see in the Execution Results pane are things
that you can create event handlers to react to within the package.
As you can see, DTS issues a quite a number of events, from
progress events to warnings about extra columns of data that we
retrieved but never used.
Try It!
1. In SQL Server Management Studio, click the Connect button at the top of the
Object Explorer window.
16-24
Try It!
2. Select Integration Services.
3. Choose the server with Integration Services installed and click Connect. This
will add an Integration Services node at the bottom of Object Explorer.
4. Expand the Stored Packages node. Youll see that you can drill down into the
File System node to find packages in the Package Store, or the MSDB node to
find packages stored in the msdb database.
5. Expand the File System node.
6. Right-click on the ExportDepartments package and select Run Package. This
will open the Execute Package utility, shown in Figure 16-13.
7. Click Execute.
8. Click Close twice to dismiss the progress dialog box and the Execute Package
Utility.
9. Enter this text into a query window with the Chapter16 database selected:
SELECT * FROM DepartmentExports
16-25
16-26
Exercises
Exercises
One common use of SSIS is in data warehousing - collecting data from a variety of
different sources into a single database that can be used for unified reporting. In this
exercise youll use SSIS to perform a simple data warehousing task.
Use SSIS to create a text file, c:\EmployeeDept.txt, containing the last names,
department names, start and end dates of the AdventureWorks2008 employees.
Retrieve the last names from the Person.Person table and the department start
and end dates from the HumanResources.EmployeeDepartmentHistory table
in the AdventureWorks2008 database, and the department names from the
Chapter16 database.
You can use the Merge Join data flow transformation to join data from two sources.
One tip: the inputs to this transformation need to be sorted on the joining column.
16-27
Solutions to Exercises
1.
2.
3.
4.
5.
6.
7.
Solutions to Exercises
35. Drag a second Sort Transformation from the Toolbox and drop it on the
Package Designer.
36. Drag a Merge Join Transformation from the Toolbox and drop it on the
Package Designer.
37. Drag a Flat File Destination from the Toolbox and drop it on the Package
Designer.
38. Click on the first OLE DB Source on the Package Designer to select it.
39. Drag the green arrow from the bottom of the first OLE DB Source and drop it
on top of the first Sort Transformation.
40. Click on the second OLE DB Source on the Package Designer to select it.
41. Drag the green arrow from the bottom of the second OLE DB Source and drop
it on top of the second Sort Transformation.
42. Click on the first Sort Transformation on the Package Designer to select it.
43. Drag the green arrow from the bottom of the first Sort Transformation and
drop it on top of the Merge Join Transformation.
44. In the Input Output Selection dialog box, select Merge Join Left Input.
45. Click OK.
46. Click on the second Sort Transformation on the Package Designer to select it.
47. Drag the green arrow from the bottom of the second Sort Transformation and
drop it on top of the Merge Join Transformation.
48. Click on the Merge Join Transformation on the Package Designer to select it.
49. Drag the green arrow from the bottom of the Merge Join Transformation and
drop it on top of the Flat File Destination. Figure 16-14 shows the Data Flow tab
with the connections between tasks.
16-29
50. Double-click the first OLE DB Source to open the OLE DB Source Editor.
51. Select the connection to the AdventureWorks2008 database.
52. For the Data Access Mode, select SQL Command.
53. Enter the following query:
SELECT p.LastName, dh.DepartmentID,
dh.StartDate, dh.EndDate
FROM
Person.Person p
INNER JOIN HumanResources.EmployeeDepartmentHistory dh
ON p.BusinessEntityID = dh.BusinessEntityID
54. Click OK.
55. Double-click the second OLE DB Source to open the OLE DB Source Editor.
56. Select the connection to the Chapter16 database.
57. Select the HumanResources.Department table.
58. Click OK.
59. Double-click the first Sort Transformation.
60. Check the DepartmentID column.
61. Click OK
16-30
Solutions to Exercises
62. Double-click the second Sort Transformation.
63. Check the DepartmentID column.
64. Click OK
65. Double-click the Merge Join Transformation.
66. Check the Join Key checkbox for the ContactID column in both tables.
67. Check the selection checkbox for the LastName, StartDate and EndDate
columns in the left-hand table and the Name column in the right-hand table;
alias the Name column as DepartmentName. Figure 16-15 shows the
completed Merge Join Transformation Editor.
16-31
16-32
Files needed:
ProductReport1.zip
ProductReport2.zip
AWSales.zip
Reporting Services
For many years, SQL Server did not have a good answer for creating attractive
reports that summarize information in ways that make sense to business users.
Finally, Microsoft shipped SQL Server Reporting Services. Like Notification
Services, Reporting Services was originally an add-on for SQL Server 2000, and now
its a part of the core product. In this chapter, youll learn how to use Reporting
Services to produce your own reports.
17-2
The Report Server database stores report definitions. Reports themselves can
make use of data from many different data sources.
Report Designer can create reports of any complexity that Reporting Services
supports, but requires you to understand the structure of your data and to be
able to navigate the Visual Studio user interface.
Report Builder provides a simpler user interface for creating ad hoc reports,
directed primarily at business users rather than developers. Report Builder
requires a developer or administrator to set up a data model before end users
can create reports.
Well start our tour of Reporting Services with Report Designer. Report Designer
runs inside the Business Intelligence Development Studio shell, and offers several
ways to create reports. You can either use the Report Wizard to quickly create a
report, or you can use a set of design tools to build a report from scratch. You can
also use the design tools to modify a report created with the wizard.
Try It!
To create a simple report using the Report Wizard, follow these steps:
1.
2.
3.
4.
17-3
Reporting Services
5. Name the new project ProductReport1 and pick a convenient location to save it
in.
6. Click OK.
7. Read the first page of the Report Wizard and click Next.
8. Name the new data source AdventureWorksDS.
9. Click the Edit button.
10. Log on to your test server.
11. Select the AdventureWorks2008 database.
12. Click OK.
13. Click the Credentials button.
14. Select Use Windows Authentication.
15. Click OK.
16. Check the Make This a Shared Data Source checkbox. This will make this
particular data source available to other Reporting Services applications in the
future.
17. Click Next.
18. Click the Query Builder button.
19. If the full query designer interface does not display by default, click the query
designer toolbar button at the far left end of the toolbar. Figure 17-2 shows the
full query designer interface.
17-4
17-5
Reporting Services
29. Select the Stepped layout and click Next.
30. Select the Ocean style and click Next.
31. Accept the default deployment location and click Next.
32. Name the report ProductReport1.
33. Check the Preview Report checkbox.
34. Click Finish.
Figure 17-4 shows the finished report, open in Report Designer.
17-6
The Report Data window shows the data that is available to the report.
The main design window lets you view the report itself. You can see a
preview of the report, work with the report in a layout designer, or work with
the query that returns the data for the report.
The Solution Explorer, Output, and Properties windows are the standard
Visual Studio windows.
Modifying a Report
Now that youve created a report with the Report Wizard, you can modify it with
the Report Designer. If youve used any sort of visual report design tool in the past,
you should have no problem making changes here. Among the possibilities here:
You can change the available data or the sort order for the report by
modifying the query.
You can resize or rearrange controls on the Design tab.
You can use the Properties window to change properties of individual
controls including their font, alignment, colors, and so on.
Try It!
To modify the report that you just created, follow these steps:
1. Click the Design tab to make the report editable.
2. In the Report Data window, right-click on DataSet1 and select Dataset
Properties.
3. In the Dataset Properties window, click the Query Designer button.
4. Select a Descending sort type for the ListPrice column and click OK.
5. Click OK.
6. Click in the textbox at the top of the report, where the report name is displayed.
7. Click a second time in the textbox to put it in edit mode and change the value
of this control to Products By Color.
8. Click on the header for the Product column.
9. Place the cursor between the column selectors above the Name and Product
Number columns to display a double-headed arrow. Hold down the mouse
button and drag the cursor to the right to widen the Name column.
10. Place the cursor between the column selectors above the Product Number
and ListPrice columns to display a double-headed arrow. Hold down the
mouse button and drag the cursor to the right to widen the Product Number
column.
11. Click on the Preview tab to view the modified report, as shown in Figure 17-5.
17-7
Reporting Services
Try It!
To create a fresh report in Report Designer, follow these steps:
1. Select File f New f Project.
17-8
17-9
Reporting Services
33. Select the Preview tab to see the report with data.
Publishing a Report
Creating reports in Business Intelligence Development Studio is good for
developers, but it doesnt help users at all. In order for the reports you build to be
available to others, you must publish them to your Reporting Services server. To
publish a report, you can use the Build and Deploy menu items in Business
Intelligence Development Studio. Before you do this, you need to check the projects
configuration to make sure that youve selected an appropriate server for the
deployment.
17-10
Publishing a Report
Try It!
You can publish any report, but the first report you created is probably more
visually interesting at this point. To publish the first report, follow these steps:
1.
2.
3.
4.
5. Click OK.
6. Select Build f Deploy ProductReport1. The Output Window will track the
progress of BIDS in deploying your report, as shown in Figure 17-8. Depending
on the speed of your computer, building the report may take some time.
17-11
Reporting Services
17-12
Try It!
To create a data model, follow these steps:
1.
2.
3.
4.
5.
6.
7.
17-13
Reporting Services
13. Right-click on Data Source Views in Solution Explorer and select Add New
Data Source View.
14. Read the first page of the Add New Data Source View Wizard and click Next.
15. Select the AdventureWorks data source and click Next.
16. Select the Product(Production) table and click the > button to move it to
the Included Objects listbox.
17. Select the SalesOrderDetail(Sales) table and click the > button to move
it to the Included Objects listbox.
18. Click the Add Related Tables button.
19. Click Next.
20. Click Finish.
21. Right-click on Report Models in Solution Explorer and select Add New Report
Model.
22. Read the first page of the Report Model Wizard and click Next.
23. Select the Adventure Works2008 data source view and click Next.
24. Keep the default rules selection, as shown in Figure 17-10, and click Next.
17-14
Building a Report
Report Builder itself is a ClickOnce Windows Forms application. That means that its
a Windows application that end users launch from their web browser, but it never
gets installed on their computer, so they dont need any local administrator rights on
their computer to run it. To get started with Report Builder, browse to your
Reporting Services home page. Typically, this will have a URL such as
Copyright 2009 Accelebrate, Inc.
17-15
Reporting Services
http://ServerName/Reports (or http://localhost/Reports if you're
running the browser on the same box with SQL Server 2008 itself). Figure 17-11
shows the Reporting Services home page.
To run Report Builder, click the Report Builder link in the home page menu bar.
Report Builder will automatically load up all of the available report models and wait
for you to choose one to build a report from.
Try It!
1. Open a browser window and navigate to http://localhost/Reports (or
to the appropriate Report Server URL if youre not working on the report
server).
2. Click the Report Builder link.
3. Depending on your operating system, you may have to confirm that you want
to run the application.
17-16
The Explorer window to the left of the design surface shows all of
the tables in the report model. Beneath that, the Fields window
shows the attributes in the currently-selected entity. Note that not
everything in this window is a column in the table: the report
model also contains aggregate entities such as Total Safety Stock
Level and automatically calculated fields.
5. Select the Product table.
6. Drag the Name field and drop it in the area labeled Drag and Drop Column
Fields.
7. Click on Special Offer Products in the Explorer window to show related
child tables.
8. Click on Sales Order Details.
9. Drag the Total Order Qty field and drop it to the right of the Name field.
10. Click where it says Click to Add Title and type Product Sales.
Copyright 2009 Accelebrate, Inc.
17-17
Reporting Services
11. Click the Run Report button to produce the report shown in Figure 17-13.
17-18
Note that reports in Report Manager open in a tabbed interface. The four tabs allow
you to perform various functions:
17-19
Reporting Services
Properties lets you adjust such things as the reports name, data source,
security credentials, caching, and end-user security.
History shows you saved snapshots of the report.
Subscriptions lets you create subscriptions to the report. Subscriptions allow
you to set up periodic delivery of reports to end users by e-mail or file share.
Users can also export the report into any of several handy formats. Table 17-1 lists
the available export formats.
Export Format
XML
CSV
PDF
MHTML
EXCEL
TIFF
Word
Handles
Creates a data file in XML format.
Creates a comma-delimited text file of report data.
Creates an Adobe Acrobat file with the formatted report.
Creates a Web Archive file with the formatted report.
Creates a MS Excel spreadsheet with the formatted
report.
Creates a TIFF graphic of the formatted report.
Creates a MS Word document with the formatted report.
Table 17-1: Export Formats
17-20
Exercises
Exercises
Use Report Builder to create a report from the AdventureWorks2008 data model
showing the minimum and maximum order quantity for orders taken by each
salesperson in the company. Youll find the necessary data in the
SalesOrderHeader and SalesOrderDetail tables.
17-21
Reporting Services
Solutions to Exercises
1. Open a browser window and navigate to http://localhost/Reports (or
to the appropriate Report Server URL if youre not working on the report
server).
2. Click the Report Builder link.
3. Select the AdventureWorks2008 report model and the table report layout.
4. Click OK.
5. Select the Sales Order Header table.
6. Drag the Sales Person ID field and drop it in the area labeled Drag and
Drop Column Fields.
7. Click on Sales Order Details in the Explorer window.
8. Expand the Total Order Qty field in the Fields window to show the
alternative fields beneath it.
9. Drag the Min Order Qty field and drop it to the right of the Name field.
10. Drag the Max Order Qty field and drop it to the right of the Min Order
Qty field.
11. Click where it says Click to Add Title and type Sales Performance.
12. Click the Run Report button to produce the report shown in Figure 17-15.
17-22
Solutions to Exercises
17-23
Files needed:
ProductReport1.zip
ProductReport2.zip
AWSales.zip
Reporting Services
For many years, SQL Server did not have a good answer for creating attractive
reports that summarize information in ways that make sense to business users.
Finally, Microsoft shipped SQL Server Reporting Services. Like Notification
Services, Reporting Services was originally an add-on for SQL Server 2000, and now
its a part of the core product. In this chapter, youll learn how to use Reporting
Services to produce your own reports.
http://www.accelebrate.com
The Report Server database stores report definitions. Reports themselves can
make use of data from many different data sources.
Report Designer can create reports of any complexity that Reporting Services
supports, but requires you to understand the structure of your data and to be
able to navigate the Visual Studio user interface.
Report Builder provides a simpler user interface for creating ad hoc reports,
directed primarily at business users rather than developers. Report Builder
requires a developer or administrator to set up a data model before end users
can create reports.
Well start our tour of Reporting Services with Report Designer. Report Designer
runs inside the Business Intelligence Development Studio shell, and offers several
ways to create reports. You can either use the Report Wizard to quickly create a
report, or you can use a set of design tools to build a report from scratch. You can
also use the design tools to modify a report created with the wizard.
Try It!
To create a simple report using the Report Wizard, follow these steps:
1.
2.
3.
4.
http://www.accelebrate.com
Reporting Services
5. Name the new report ProductReport1 and pick a convenient location to save it
in.
6. Click OK.
7. Read the first page of the Report Wizard and click Next.
8. Name the new data source AdventureWorksDS.
9. Click the Edit button.
10. Log on to your test server.
11. Select the AdventureWorks database.
12. Click OK.
13. Click the Credentials button.
14. Select Use Windows Authentication.
15. Click OK.
16. Check the Make This a Shared Data Source checkbox. This will make this
particular data source available to other Reporting Services applications in the
future.
17. Click Next.
18. Click the Query Builder button.
19. If the full query designer interface does not display by default, click the query
designer toolbar button at the far left end of the toolbar. Figure 18-2 shows the
full query designer interface.
http://www.accelebrate.com
http://www.accelebrate.com
Reporting Services
http://www.accelebrate.com
The Datasets window shows the data that is available to the report.
The main design window lets you view the report itself. You can see a
preview of the report, work with the report in a layout designer, or work with
the query that returns the data for the report.
The Solution Explorer, Output, and Properties windows are the standard
Visual Studio windows.
Modifying a Report
Now that youve created a report with the Report Wizard, you can modify it with
the Report Designer. If youve used any sort of visual report design tool in the past,
you should have no problem making changes here. Among the possibilities here:
http://www.accelebrate.com
Reporting Services
You can change the available data or the sort order for the report by
modifying the query on the Data tab.
You can resize or rearrange controls on the Layout tab.
You can use the Properties window to change properties of individual
controls including their font, alignment, colors, and so on.
Try It!
To modify the report that you just created, follow these steps:
1.
2.
3.
4.
5.
6.
7.
8.
9.
Click the Data tab to view the query for the report.
Select a Descending sort type for the ListPrice column.
Click the Layout tab.
Click in the textbox at the top of the report, where the report name is displayed.
Use the Properties window to change the Value property of this control to
Products By Color.
Click on the header for the Product column.
Place the cursor between the Name and Product Number columns to display a
double-headed arrow. Hold down the mouse button and drag the cursor to the
right to widen the Name column.
Place the cursor between the Product Number and ListPrice columns to display
a double-headed arrow. Hold down the mouse button and drag the cursor to
the right to widen the Product Number column.
Click on the Preview tab to view the modified report, as shown in Figure 18-5.
http://www.accelebrate.com
Try It!
To create a fresh report in Report Designer, follow these steps:
1.
2.
3.
4.
http://www.accelebrate.com
Reporting Services
5. Name the new report ProductReport2 and pick a convenient location to save it
in.
6. Right-click on the Reports node in Solution Explorer and select Add f New
Item.
7. Select the Report template.
8. Name the new report ProductReport2.rdl and click Add.
9. Select the Data tab in the Report Designer.
10. Click the Datasets dropdown and select <New Dataset> to open the Data
Source dialog box.
11. Name the new Data Source AdventureWorksDS.
12. Click the Edit button.
13. Connect to your test server and choose the AdventureWorks database.
14. Click OK.
15. Click OK again to create the data source.
16. Click the Query Designer toolbar button inside the Data tab to display the full
query designer user interface.
17. Click the Add Table button.
18. Select the Location table.
19. Click Add.
20. Click Close.
21. Check the boxes for the Name and CostRate columns.
22. Sort the dataset in ascending order by Name.
23. Click the Layout tab to show the blank report layout.
24. Hover your mouse over the toolbox tab to display the available controls for the
report.
25. Double-click the List control.
26. Expand the List control to the width of the report.
27. Expand the dataset in the Datasets window to show the column names.
28. Drag the Name and CostRate columns from the Datasets window and drop
them in the List control. Expand them horizontally until each takes up about
half of the List control. Figure 18-6 shows the report in layout view.
http://www.accelebrate.com
Publishing a Report
29. Select the Preview tab to see the report with data.
Publishing a Report
Creating reports in Business Intelligence Development Studio is good for
developers, but it doesnt help users at all. In order for the reports you build to be
available to others, you must publish them to your Reporting Services server. To
publish a report, you can use the Build and Deploy menu items in Business
Intelligence Development Studio. Before you do this, you need to check the projects
configuration to make sure that youve selected an appropriate server for the
deployment.
Try It!
To publish a report, follow these steps:
http://www.accelebrate.com
Reporting Services
1.
2.
3.
4.
5.
6.
7. Click Close.
8. Fill in the URL for your Report Server. If youre developing on the same
computer where Reporting Services is installed, and you installed in the default
configuration, this will be http://localhost/ReportServer. Figure 18-8 shows
the completed Property Pages.
http://www.accelebrate.com
Publishing a Report
9. Click OK.
10. Select Build f Deploy ProductReport1. The Output Window will track the
progress of BIDS in deploying your report, as shown in Figure 18-9. Depending
on the speed of your computer, building the report may take some time.
http://www.accelebrate.com
Reporting Services
17. If prompted, supply your username and password. The report will open in
your Web browser.
Try It!
To create a data model, follow these steps:
1.
2.
3.
4.
5.
6.
7.
http://www.accelebrate.com
http://www.accelebrate.com
Reporting Services
25. Choose the Update Statistics option and click Next.
26. Click Run to complete the wizard.
27. Click Finish. If you get a warning that a file was modified outside the source
editor, click Yes.
28. Select Build f Deploy AWSales to deploy the report model to the local
Reporting Services server.
Building a Report
Report Builder itself is a ClickOnce Windows Forms application. That means that
end users install it from the browser, but once installed it's not a browser-based
application. To get started with Report Builder, browse to your Reporting Services
home page. Typically, this will have a URL such as
http://ServerName/Reports (or http://localhost/Reports if you're
running the browser on the same box with SQL Server 2005 itself). Figure 18-11
shows the Reporting Services home page.
To install Report Builder, click the Report Builder link in the home page menu bar.
Report Builder will automatically load up all of the available report models and wait
for you to choose one to build a report from.
http://www.accelebrate.com
Try It!
1. Open a browser window and navigate to http://localhost/Reports (or
to the appropriate Report Server URL if youre not working on the report
server).
2. Click the Report Builder link.
3. Depending on your operating system, you may have to confirm that you want
to run the application.
4. After Report Builder is installed, select the AdventureWorks report model and
the table report layout. Click OK. Figure 18-12 shows the new blank report that
Report Builder will create.
http://www.accelebrate.com
Reporting Services
The Explorer window to the left of the design surface shows all of
the tables in the report model. Beneath that, the Fields window
shows the entities in the currently-selected table. Note that not
everything in this window is a column in the table: the report
model also contains aggregate entities such as Total Safety Stock
Level and automatically calculated fields.
5. Select the Product table.
6. Drag the Name field and drop it in the area labeled Drag and Drop Column
Fields.
7. Click on Special Offer Products in the Explorer window to show related child
tables.
8. Click on Sales Order Details.
9. Drag the Total Order Qty field and drop it to the right of the Name field.
10. Click where it says Click to Add Title and type Product Sales.
11. Click the Run Report button to produce the report shown in Figure 12-13.
http://www.accelebrate.com
http://www.accelebrate.com
Reporting Services
http://www.accelebrate.com
http://www.accelebrate.com
Reporting Services
Exercises
Use Report Builder to create a report from the AdventureWorks data model
showing the minimum and maximum order quantity for orders taken by each
salesperson in the company. Youll find the necessary data in the SalesOrderHeader
and SalesOrderDetail tables.
http://www.accelebrate.com
Solutions to Exercises
Solutions to Exercises
1. Open a browser window and navigate to http://localhost/Reports (or
to the appropriate Report Server URL if youre not working on the report
server).
2. Click the Report Builder link.
3. Select the AdventureWorks report model and the table report layout.
4. Click OK.
5. Select the Sales Order Header table.
6. Drag the Sales Person ID field and drop it in the area labeled Drag and Drop
Column Fields.
7. Click on Sales Order Details in the Explorer window.
8. Expand the Total Order Qty field in the Fields window to show the alternative
fields beneath it.
9. Drag the Min Order Qty field and drop it to the right of the Name field.
10. Drag the Max Order Qty field and drop it to the right of the Min Order Qty
field.
11. Click where it says Click to Add Title and type Sales Performance.
12. Click the Run Report button to produce the report shown in Figure 18-15.
http://www.accelebrate.com
Reporting Services
http://www.accelebrate.com