Microsoft ® SQL Server ® 2008Ashwani Nanda New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto Hands-On IntegratIO
Trang 2Microsoft ® SQL Server ® 2008
Ashwani Nanda
New York Chicago San Francisco Lisbon
London Madrid Mexico City Milan
New Delhi San Juan Seoul Singapore
Sydney Toronto
Hands-On
IntegratIOn servIces
Trang 3Copyright © 2011 by The McGraw-Hill Companies All rights reserved Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database
or retrieval system, without the prior written permission of the publisher.
ISBN: 978-0-07-173641-1
MHID: 0-07-173641-7
The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-173640-4,
MHID: 0-07-173640-9.
All trademarks are trademarks of their respective owners Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefi t of the trademark owner, with no intention of infringement of the trademark Where such designations appear in this book, they have been printed with initial caps.
McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs To contact a representative please e-mail us at bulksales@mcgraw-hill.com.
Information has been obtained by McGraw-Hill from sources believed to be reliable However, because of the possibility of human or mechanical error by our sources, McGraw-Hill, or others, McGraw-Hill does not guarantee the accuracy, adequacy,
or completeness of any information and is not responsible for any errors or omissions or the results obtained from the use of such information.
TERMS OF USE
This is a copyrighted work and The McGraw-Hill Companies, Inc (“McGrawHill”) and its licensors reserve all rights in and to the work Use of this work is subject to these terms Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill’s prior consent You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohib-ited Your right to use the work may be terminated if you fail to comply with these terms.
THE WORK IS PROVIDED “AS IS.” McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom McGraw-Hill has no responsibility for the content of any information accessed through the work Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility
of such damages This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.
Trang 4To my kids—With practice you can perform impossible tasks easily
Trang 5About the Author
Ashwani Nanda develops and maintains marketing, analytical, and CRM-based
database systems for medium- to large-sized enterprises His current area of
specialization is data modeling, database development, business intelligence reporting, and analysis He started his career on real-time mainframe systems back in the age when hard disks used to weigh a kilo per megabyte Moving from system engineering for mainframes to networking and infrastructure support, then to database management and currently to business intelligence, he has worked for several major hardware and software vendors He loves to integrate disparate technologies utilizing the best features
of available applications These days he is using his business intelligence skills to create data visualization reports He can be reached at ananda@AffordingIT.co.uk
About the Technical Editor
Allan Mitchell started his love affair with ETL in SQL Server 7 and Data
Transformation Services He moved on to SSIS with SQL Server 2005 and has traveled the world working with clients big and small who have complex data
integration issues He lives in the UK and is married to Lesley They have a
wonderful son, Ewan
Trang 6Contents at a Glance
Chapter 1 Introducing SQL Server Integration Services 1
Chapter 2 Getting Started with Wizards 41
Chapter 3 Nuts and Bolts of the SSIS Workflow 69
Chapter 4 Integration Services Control Flow Containers 109
Chapter 5 Integration Services Control Flow Tasks 135
Chapter 6 Administering Integration Services 225
Chapter 7 Securing Integration Services Packages 269
Chapter 8 Advanced Features of Integration Services 291
Chapter 9 Data Flow Components 333
Chapter 10 Data Flow Transformations 377
Chapter 11 Programming Integration Services 481
Chapter 12 Data Warehousing and SQL Server 2008 Enhancements 535
Chapter 13 Deploying Integration Services Packages 567
Chapter 14 Migrating to Integration Services 2008 595
Chapter 15 Troubleshooting and Performance Enhancements 631
Appendix How to Use the Provided Software 673
Index 677
Trang 7This page intentionally left blank
Trang 8Contents
Acknowledgments xix
Introduction xxi
Chapter 1 Introducing SQL Server Integration Services 1
Integration Services: Features and Uses 4
Integration Services Architecture 4
Integration Services Designer and Management Tools 4
Data Warehousing Loading 5
Standardizing and Enhancing Data Quality Features 6
Converting Data into Meaningful Information 7
Data Consolidation 7
Package Security Features 7
Service-Oriented Architecture 8
SSIS Package as a Data Source 8
Programmability 8
Scripting 9
Easy Management of SSIS Packages 9
Automating Administrative Tasks 10
Easy Deployment Features 10
Legacy Support Features 10
What’s New in Integration Services 2008 10
Better Lookup 11
Improved ADO NET Components 12
Powerful Scripting 12
Extended Import and Export Wizard 12
Ability to Profile Your Data 12
Optimized Thread Allocation 13
SSIS Package Upgrade Wizard 13
Taking Advantage of Change Data Capture 13
Benefiting from T-SQL Merge Statement 13
Enhanced Debugging 14
Inclusion of New Date and Time Data Types 14
Where Is DTS in SQL Server 2008? 14
Trang 9v i i i H a n d s - O n M i c r o s o f t S Q L S e r v e r 2 0 0 8 I n t e g r a t i o n S e r v i c e s
Integration Services in SQL Server 2008 Editions 15
32-Bit Editions vs 64-Bit Editions 17
Integration Services Architecture 18
Integration Services Service 19
Integration Services Object Model 20
Integration Services Run Time 20
Integration Services Data Flow 20
Installing Integration Services 21
Installing Integration Services on a Clean System 21
Hands-On: Installing SQL Server 2008 Integration Services 22
Installing Integration Services from the Command Prompt 25
Installing Side by Side 26
Upgrading to SQL Server 2008 Integration Services 27
Business Intelligence Development Studio 28
Hands-On: Creating a Blank Integration Services Project 29
SQL Server Management Studio 37
Hands-On: Connecting to Integration Services Service 37
Summary 39
Chapter 2 Getting Started with Wizards 41
Starting SQL Server Import and Export Wizard 43
Hands-On: Importing a Flat File into SQL Server 2008 43
Using Business Intelligence Development Studio 53
Hands-On: Exploring an SQL Server Import and Export Wizard Package Using BIDS 53
Integration Services Connections Project Wizard 63
Analyzing Data Quality with the Data Profiling Task 63
Single-Column Profiles 64
Multiple-Column Profiles 65
Hands-On: Using Data Profiling Task 66
Summary 68
Chapter 3 Nuts and Bolts of the SSIS Workflow 69
Integration Services Objects 70
Solutions and Projects 71
File Formats 73
Fixed Width 73
Delimited 73
Ragged Right 74
Trang 10C o n t e n t s i x
Connection Managers 74
ADO Connection Manager 75
ADO NET Connection Manager 75
Cache Connection Manager 76
Excel Connection Manager 76
File Connection Manager 77
Flat File Connection Manager 78
FTP Connection Manager 78
HTTP Connection Manager 78
MSMQ Connection Manager 78
Analysis Services Connection Manager 78
Multiple Files Connection Manager 79
Multiple Flat Files Connection Manager 79
ODBC Connection Manager 80
OLE DB Connection Manager 80
SMO Connection Manager 80
SMTP Connection Manager 81
SQL Server Compact Edition Connection Manager 81
WMI Connection Manager 81
Microsoft Connector 1 0 for SAP BI 81
Microsoft Connector for Oracle by Attunity 82
Microsoft Connector for Teradata by Attunity 83
Data Sources and Data Source Views 84
Data Sources 84
Data Source View 85
SSIS Variables 86
System Variables 87
Hands-On: Using System Variables to Create Custom Logs 87
User-Defined Variables 93
Hands-On: Creating a Directory with User-Defined Variables 95
Precedence Constraints 99
Constraint Options 100
Multiple Constraints 102
Integration Services Expressions 102
Hands-On: Using Expressions to Update Properties at Run Time 105
Summary 107