Tải bản đầy đủ (.pdf) (916 trang)

Professional Microsoft SQL Server 2008 Administration ppt

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (18.16 MB, 916 trang )

Professional
Microsoft
®
SQL Server
®
2008 Administration
www.wrox.com
$49.99 USA
$54.99 CAN
Wrox Professional guides are planned and written by working programmers to meet the real-world needs of programmers,
developers, and IT professionals. Focused and relevant, they address the issues technology professionals face every day. They
provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job.
Recommended
Computer Book
Categories
Database Management
General
ISBN: 978-0-470-24796-9
SQL Server 2008 represents a significant jump forward in scalability
and performance. Database administrators — and developers as well —
will need to master new methods for effectively managing increasingly
large and complex SQL Server environments.
This author team of SQL Server experts arms you with unique tips,
tricks, and workarounds, including managing and monitoring SQL
Server, automating administration, clustering, performance tuning,
handling backup and recovery, and more. You’ll learn the various tools
that are available to you with the 2008 release, as well as new features
such as Performance Studio, Change Data Capture, Policy-based
Management, and Query Governor. With a solid understanding of SQL
Server 2008, you’ll be able to confidently handle even the most difficult
SQL Server admin issues.


What you will learn from this book
● Best practices for SQL Server 2008 installation
● Tips for troubleshooting and securing the database engine
● How to automate SQL Server
● Ways to index your database
● Methods for monitoring your SQL Server instance
● How to performance tune your SQL Server instance
Who this book is for
This book is for experienced database administrators who are
interested in learning best pratices for administering SQL Server 2008.
Enhance Your Knowledge
Advance Your Career
Microsoft
®
SQL Server
®
2008
Administration
Knight, Patel, Snyder,
LoForte, Wort
Professional
subtitle
spine=1.728"
Professional
Microsoft
®
SQL Server
®
2008
Administration

Brian Knight, Ketan Patel, Wayne Snyder, Ross LoForte, Steven Wort
Updates, source code, and Wrox technical support at www.wrox.com
Wrox Programmer to Programmer
TM
Wrox Programmer to Programmer
TM
Professional
Microsoft
®
SQL Server
®
2008 Administration
Enhance Your Knowledge
Advance Your Career
Professional Microsoft SQL Server 2008 Integration
Services
978-0-470-24795-2
This book shows developers how to master the 2008 release of SSIS, covering topics
including data warehousing with SSIS, new methods of managing the SSIS platform,
and improved techniques for ETL operations.
Professional SQL Server 2008 Reporting Services
978-0-470-24201-8
This book teaches solutions architects, designers, and developers how to use
Microsoft’s reporting platform to create reporting and business intelligence solutions.
Professional Microsoft SQL Server 2008 Analysis Services
978-0-470-24798-3
Professional Microsoft SQL Server 2008 Analysis Services shows readers how to
build data warehouses and multidimensional databases, query databases, and
use Analysis Services and other components of SQL Server to provide end-to-end
solutions.

Professional Microsoft SQL Server 2008 Programming
978-0-470-25702-9
This updated new edition of Wrox’s best-selling SQL Server book has been expanded
to include coverage of SQL Server 2008’s new datatypes, new indexing structures,
manageability features, and advanced time-zone handling.
Professional Microsoft SQL Server 2008 Administration
978-0-470-24796-9
A how-to guide for experienced database administrators, this book is loaded with
unique tips, tricks, and workarounds for handling the most difficult SQL Server
administration issues. The authors discuss data capture, performance studio, Query
Governor, and new techniques for monitoring and policy management.
Beginning Microsoft SQL Server 2008 Programming
978-0-470-25701-2
This comprehensive introduction to SQL Server covers the fundamentals and moves on to discuss how to create and change tables, manage
keys, write scripts, work with stored procedures, and much more.
Beginning T-SQL with Microsoft SQL Server 2005 and 2008
978-0-470-25703-6
Beginning T-SQL with Microsoft SQL Server 2005 and 2008 provides a comprehensive introduction to the T-SQL programming language, with
concrete examples showing how T-SQL works with both SQL Server 2005 and SQL Server 2008.
Beginning Database Design Solutions
978-0-470-38549-4
Beginning Database Design Solutions introduces IT professionals—both DBAs and database developers—to database design. It explains what
databases are, their goals, and why proper design is necessary to achieve those goals. It tells how to decide what should be in a database to
meet the application’s requirements. It tells how to structure the database so it gives good performance while minimizing the chance for error.
Get more out of
WROX.com
Programmer to Programmer

Interact
Take an active role online by participating in

our P2P forums
Wrox Online Library
Hundreds of our books are available online
through Books24x7.com
Wrox Blox
Download short informational pieces and
code to keep you up to date and out of
trouble!
Chapters on Demand
Purchase individual book chapters in pdf
format
Join the Community
Sign up for our free monthly newsletter at
newsletter.wrox.com
Browse
Ready for more Wrox? We have books and
e-books available on .NET, SQL Server, Java,
XML, Visual Basic, C#/ C++, and much more!
Contact Us.
We always like to get feedback from our readers. Have a book idea?
Need community support? Let us know by e-mailing
spine=1.728"
Knight ffirs.tex V1 - 10/01/2008 4:16am Page i
Professional Microsoft

SQL Server

2008 Administration
Introduction xxix
Chapter 1: SQL Server 2008 Architecture

1
Chapter 2: SQL Server 2008 Installation Best Practices
35
Chapter 3: Upgrading SQL Server 2008 Best Practices
63
Chapter 4: Managing and Troubleshooting the Database Engine
97
Chapter 5: Automating SQL Server
129
Chapter 6: Integration Services Administration and Performance Tuning
175
Chapter 7: Analysis Services Administration and Performance Tuning
207
Chapter 8: Administering the Development Features
237
Chapter 9: Securing the Database Engine
329
Chapter 10: Change Management
383
Chapter 11: Configuring the Server for Optimal Performance
413
Chapter 12: Optimizing SQL Server 2008
455
Chapter 13: Monitoring Your SQL Server
497
Chapter 14: Performance Tuning T-SQL
555
Chapter 15: Indexing Your Database
605
Chapter 16: Replication

653
Chapter 17: Database Mirroring
683
Chapter 18: Backup and Recovery
731
Chapter 19: SQL Server 2008 Log Shipping
779
Chapter 20: Clustering SQL Server 2008
807
Index
839
Knight ffirs.tex V1 - 10/01/2008 4:16am Page ii
Knight ffirs.tex V1 - 10/01/2008 4:16am Page iii
Professional
Microsoft

SQL Server

2008
Administration
Knight ffirs.tex V1 - 10/01/2008 4:16am Page iv
Knight ffirs.tex V1 - 10/01/2008 4:16am Page v
Professional
Microsoft

SQL Server

2008
Administration
Brian Knight

Ketan Patel
Wayne Snyder
Ross LoForte
Steven Wort
Wiley Publishing, Inc.
Knight ffirs.tex V1 - 10/01/2008 4:16am Page vi
Professional Microsoft

SQL Server

2008 Administration
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-24796-9
Manufactured in the United States of America
10987654321
Library of Congress Cataloging-in-Publication Data
Microsoft SQL server 2008 administration / Brian Knight [et al.].
p. cm.
Includes index.
ISBN 978-0-470-24796-9 (paper/website)
1. SQL server. 2. Database management. I. Knight, Brian.
QA76.9.D3M57366 2008
005.75’85 — dc22
2008037353

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317)
572-3447, fax (317) 572-4355, or online at
www.wiley.com/go/permissions
.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties
with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties,
including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended
by sales or promotional materials. The advice and strategies contained herein may not be suitable for every
situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting,
or other professional services. If professional assistance is required, the services of a competent professional person
should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an
organization or Website is referred to in this work as a citation and/or a potential source of further information
does not mean that the author or the publisher endorses the information the organization or Website may provide
or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may
have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress
are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other
countries, and may not be used without written permission. Microsoft and SharePoint are registered trademarks of
Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their
respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.
Knight fabout.tex V1 - 10/01/2008 4:21am Page vii

About the Authors
Brian Knight, SQL Server MVP, MCSE, MCDBA, is the co-founder of SQLServerCentral.com and Jump-
startTV.com. Brian is a principal consultant and owner of Pragmatic Works. He runs the local SQL
Server users group (JSSUG) in Jacksonville, Florida, and was on the Board of Directors of the Profes-
sional Association for SQL Server (PASS). Brian is a contributing columnist for SQL Server Standard,
maintains a regular column for the database website SQLServerCentral.com, and does regular webcasts
at Jumpstart TV. He is the author of nine SQL Server books. Brian is a speaker at numerous confer-
ences, including PASS, SQL Connections, and TechEd, and many code camps. His blog can be found at
www.pragmaticworks.com
. Brian spends weekends practicing to be an amateur surgeon and proceeds
from this book will help pay for the mobile CAT scan for his van.
Ketan Patel, B.E., electronics engineering, MCSE, MCDBA, is a senior development manager for the
Business Intelligence Center of Excellence group at Microsoft. He has worked with SQL Server and other
Microsoft technologies for nearly nine years. Ketan has also spoken at TechEd. He spends his spare time
with his family and friends, playing cricket and watching NFL.
Wayne Snyder is recognized worldwide as a SQL Server expert and Microsoft Most Valued Professional
(MVP), with over 25 years of experience in project management, database administration, software
design, performance measurement, and capacity planning. He is a popular consultant, trainer, writer,
and speaker, and produces a series of Web-based seminars on SQL Server 2005. Wayne has edited
many SQL Server books, has SQL Training CDs with Learnkey, is president of PASS, the Professional
Association for SQL Server (
www.sqlpass.org
), plays keyboard for a cover band named SoundBar-
rier (
www.soundbarrierband.com
), and is a managing consultant for Mariner, a Business Intelligence
Company (
www.mariner-usa.com
).
Ross LoForte is a technical architect at the Microsoft Technology Center Chicago, focused on Microsoft

SQL Server solutions. Ross has more than 16 years of experience in business development, project man-
agement, and designing SQL architecture solutions. For the past eight years, Ross has been working with
the Microsoft Technology Centers, and has led architecture design and proof-of-concept engagements
for Microsoft’s largest and most strategic customers to design enterprise, mission-critical SQL Server
solutions. Ross is a SQL Server instructor at DePaul University in Chicago, and regularly presents at
TechEd, SQL PASS, Gartner, TDWI, and other conferences. A published author, he has been active with
the Professional Association for SQL Server, the Chicago SQL Server Users Group, and the SQL Server
community for many years.
Steven Wort has been working with SQL Server for the past 14 years. He spent much of that time working
as a freelance application developer and database architect building VB and Web applications on SQL
Server for many of London’s largest financial institutions. He moved to the United States nine years ago,
joining Microsoft over seven years ago. After three years working in PSS on the SIE team, he moved over
to the SQL Server Product group, spending a year working on SQL Server scalability, followed by a year
working with the SQL Playback team. Two years ago Steven moved to the Windows division, where he
started work on the SQL Server side of the Watson system. When he is not involved with technology,
Steven can be found doing something active somewhere outdoors in the Pacific Northwest.
Geoff Hiten, a Microsoft MVP, is a senior SQL Server consultant based in Atlanta. Geoff began
working with SQL Server in 1992 with version 4.2 and has used every version since. He specializes in
high-availability and high-performance SQL systems. Recent projects include: system upgrades, SQL
Server platform migrations, performance tuning, custom reporting solutions, and database strategy
implementations. Geoff is currently on the leadership team of the Atlanta area Microsoft Database Forum
Knight fabout.tex V1 - 10/01/2008 4:21am Page viii
About the Authors
Users group (AtlantaMDF) and can be found lurking in the halls at PASS (Professional Association
for SQL Server) Community Summit events. In addition, Geoff has been a Subject Matter Expert for
Microsoft Training Curriculum materials and has authored articles, white papers, and podcasts on SQL
Server.
K. Brian Kelley (MCSE, Security+ , CISA) is a systems and security architect for AgFirst Farm Credit
Bank. At AgFirst he provides infrastructure and security guidance with respect to Windows-based tech-
nologies including Active Directory, Internet Information Server, and Microsoft SQL Server. Brian, author

of Start to Finish Guide to SQL Server Performance Monitoring and contributing author for How to Cheat at
Securing SQL Server 2005, is a regular columnist and blogger at SQLServerCentral.com focusing primarily
on SQL Server security. He is also a frequent contributor for SQL Server Standard Magazine. Brian is a
member of the Professional Association of SQL Server (PASS) and the Information Systems Audit and
Control Association (ISACA). He is also active in the Midlands PASS chapter, an official PASS chapter
for South Carolina.
viii
Knight fcre.tex V1 - 10/01/2008 8:37am Page ix
Credits
Executive Editor
Robert Elliott
Development Editor
Sara Shlaer
Technical Editor
John Mueller
Production Editor
Kathleen Wisor
Copy Editor
Luann Rouff
Editorial Manager
Mary Beth Wakefield
Production Manager
Tim Tate
Vice President and Executive Group
Publisher
Richard Swadley
Vice President and Executive
Publisher
Joseph B. Wikert
Project Coordinator, Cover

Lynsey Stanford
Proofreader
Nancy Carrasco
Publication Services, Inc.
Indexer
Robert Swanson
Knight fcre.tex V1 - 10/01/2008 8:37am Page x
Knight fack.tex V1 - 10/01/2008 4:22am Page xi
Acknowledgments
As always, I must thank my wife and best friend for supporting me for the past 10 years of marriage.
I’ve been fortunate to have found a woman who doesn’t fall asleep immediately when copyediting my
technical writing. Thanks to my three children, Colton, Liam, and Camille, for allowing their daddy
to be distracted sometimes with this book when they wanted to play. Thanks also to all the wonderful
co-authors, who truly made this book possible. Once again, I must thank the Pepsi-Cola Company for
inventing Mountain Dew, which drove the late night writing. — Brian Knight
I would like to thank my parents, Thakorbhai and Induben, for their unwavering and selfless support and
inspiration in my life, and my wife, Sweety, for her invaluable support and understanding. I would like to
acknowledge Brian Knight, the lead author, for providing me with a great opportunity to co-author this
book. I would also like to acknowledge Sara Shlaer, the development editor, and John Mueller, technical
editor — without them this book would not exist or contain the level of depth that it has. Last but not the
least, I want to thank B. J. Moore and Jim Walch, both general managers at Microsoft, for their invaluable
support and encouragement. — Ketan Patel
Thank-you to my loving wife, Vickie, whose generosity and support make my life better each day.
— Wayne Snyder
I’d like to thank my wife, Anna, and my daughter, Jennifer, for their support while writing this book.
Additionally, I’d like to thank Adam Hecktman and Tony Surma for their support, and for making the
Microsoft Technology Center Chicago a great facility to learn and experience. — Ross LoForte
I have to start by thanking my wife, Tracy, and two daughters, Eleanor and Caitlin, for putting up with
me over the past few months of writing. They have been infinitely patient and understanding while I
have spent many long hours working. I must also thank everyone in the SQL Product Group who has

helped me with information about SQL Server 2008. Finally, I would like to thank everyone at Wrox
Press for their help with this work over the past months. — Steven Wort
I would like to thank my wife Cheryl for being my other, better half, and my children; Victoria, Alexan-
dra, and Katherine, who challenge me to do better simply by being who they are. — Geoff Hiten
Thanks to Kimberly, my beautiful bride and my children, James, Paul, and Faye. I love you all very much.
Thanks also to Brian Knight for opening the door and to Mark Melichar for encouraging me to seize the
opportunity. You guys have been great mentors and I can’t thank you enough. — K. Brian Kelly
Knight fack.tex V1 - 10/01/2008 4:22am Page xii
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xiii
Contents
Introduction xxix
Chapter 1: SQL Server 2008 Architecture 1
The Expanding Role of a DBA 1
Production DBA 1
Development DBA 2
Business Intelligence DBA 3
Hybrid DBA 3
New Things You Need to Learn 4
SQL Server Architecture 5
Transaction Log and Database F iles 5
SQL Native Client 6
System Databases 7
Schemas 9
Synonyms 9
Dynamic Management Views 10
SQL Server 2008 Data Types 10
Editions of SQL Server 16
Compact (32-bit only) 17
SQL Express (32-bit only) 17
Workgroup Edition (32-bit and 64-bit) 17

Web Edition (32-bit and 64-bit) 17
Standard Edition (32-bit and 64-bit) 17
Enterprise, Evaluation, and Developer Editions (32-bit and 64-bit) 17
Operating System 18
Maximum Capacity of SQL Server 18
Database Features By Edition 19
Licensing 31
Summary 34
Chapter 2: SQL Server 2008 Installation Best Practices 35
Planning the System 35
Hardware Options 36
Software and Install Options 40
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xiv
Contents
Installing SQL Server 45
Side-By-Side, Upgrade, and New Installs 45
Scripted Installation 46
Remote Installation 47
Local Installation 47
Where Are the Sample Databases? 50
Installing Analysis Services 51
Burning in the System 52
Post-Install Configuration 52
SQL Server Configuration Manager 53
SQL Server Management Studio 53
tempdb 54
Back It Up 56
Uninstalling SQL Server 57
Uninstalling Reporting Services 57
Uninstalling Analysis Services 58

Uninstalling the SQL Server Database Engine 58
Common Installation Issues 59
Installing Client Tools from a Network Share 59
Admin Tools Not Installed by Default on Remote Cluster Nodes 60
Minimum Configuration Warning 60
Troubleshooting a Failed Install 60
Summary 61
Chapter 3: Upgrading SQL Server 2008 Best Practices 63
Why Upgrade to SQL Server 2008? 63
Risk Mitigation — The Microsoft Contribution 64
Independent Software Vendors and SQL Community Contributions 65
Upgrading to SQL Server 2008 65
In-Place Upgrading 66
Side-by-Side Upgrade 67
In-Place Upgrade versus Side-By-Side Upgrade Considerations 67
Pre-Upgrade Checks 69
SQL Server Upgrade Advisor 69
Installing the SQL Server 2008 Upgrade Advisor 69
Using the Upgrade Advisor 70
Scripting the Upgrade Advisor 72
Resolving Upgrade Issues 73
SQL Server 2008 Upgrade Assistant 75
Backward Compatibility 77
Unsupported and Discontinued Features 77
SQL Server 2008 Deprecated Database Features 78
Other SQL Server 2008 Changes Affecting Behavior 78
xiv
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xv
Contents
SQL S erver Component Considerations 79

Upgrading Full-Text Catalog to SQL Server 2008 79
Upgrading Reporting Services 80
Upgrading Analysis Services 80
Upgrading DTS to SQL Server 2008 Integration Services (SSIS) 81
Log Shipping 88
Failover Clustering and Data Mirroring 88
Upgrading to 64-bit 88
Post-Upgrade Checks 89
Poor Query Performance After Upgrade 89
Updating Usage Counters 90
SQL Server Configuration Manager 91
Policy-Based Management 91
Summary 96
Chapter 4: Managing and Troubleshooting the Database Engine 97
Configuration Tools 97
SQL Server Configuration Manager 97
Dedicated Administrator Connection 99
Configuration Servers and Server Groups 100
Startup Parameters 101
Startup Stored Procedures 104
Rebuilding the System Databases 105
Management Studio 106
Reports 106
Configuring SQL Server 108
Filtering Objects 112
Error Logs 113
Activity Monitor 114
Monitoring Processes in T-SQL 118
Trace Flags 120
Getting Help from Support 124

SQLDumper.exe 124
SQLDiag.exe 125
Summary 127
Chapter 5: Automating SQL Server 129
Maintenance Plans 129
Maintenance Plan Wizard 130
Maintenance Plan Designer 132
SQL S erver Agent 136
Automation Components 137
SQL Server Agent Security 151
xv
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xvi
Contents
Configuring SQL Server Agent 156
Database Mail 160
Multiserver Administration 166
Summary 172
Chapter 6: Integration Services Administration and Performance Tuning 175
A Tour of Integration Services 175
Integration Services Uses 176
The Four Main Parts of Integration Services 177
Project Management and Change Control 179
Administration of the Integration Services Service 179
An Overview of the Integration Services Service 179
Configuration 180
Event Logs 185
Monitoring Activity 187
Administration of Integration Services Packages 187
An Overview of Integration Services Packages 187
Creating Packages 188

Management 191
Deployment 194
Execution and Scheduling 199
Applying Security to Integration Services 203
An Overview of Integration Services Security 203
Securing Packages 203
Saving Packages 205
Running Packages 205
Package Resources 205
Digital Signatures 206
Summary 206
Chapter 7: Analysis Services Administration and Performance Tuning 207
Tour of Analysis Services 207
Unified Dimensional Model Components 208
Analysis Services Architectural Components 209
Administering Analysis Services Server 210
Required Services 212
Analysis Services Scripting Language 212
Administering Analysis Services Databases 214
Deploying Analysis Services Databases 214
Processing Analysis Services Objects 217
Backing Up and Restoring Analysis Services Databases 219
Synchronizing Analysis Services Databases 222
xvi
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xvii
Contents
Analysis Services Performance Monitoring and Tuning 223
Monitoring Analysis Services Events Using SQL Profiler 223
Creating Traces for Replay 224
Using Flight Recorder for After-the-Fact Analysis 226

Management of Analysis Services Storage 227
Storage Modes 227
Partition Configuration 227
Designing Aggregations 228
Applying Security to Analysis Services 233
Server Role 233
Database Role 233
Database Role Permissions 234
Summary 236
Chapter 8: Administering the Development Features 237
Service Broker 237
Service Broker Architecture 238
Service Broker Examples 246
Activation 260
Conversation Groups 265
Security Considerations for Service Broker 267
Transport Security 267
Routing 271
Dialog Security 275
Conversation Priorities 279
Setting Conversation Priorities 279
Reviewing Conversation Priorities 288
Administering Service Broker 288
Installing Service Broker Application 289
Setting Permission on Service Broker Objects 290
Managing Service Broker Queues 292
Poison Message Handling 293
Moving Service Broker Applications 295
Copying Service Broker Applications 296
Replacing Expired Certificates 297

Troubleshooting Service Broker Applications 297
Performance Tuning Service Broker 307
Introduction to CLR Integration 308
SQL Server As .NET Runtime Host 308
Application Domains 309
T-SQL versus CLR 310
Extended Stored Procedures versus CLR 310
xvii
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xviii
Contents
Enabling CLR Integration 311
Creating the CLR Assembly 312
Deploying the Assembly 315
Cataloging Objects 321
Application Domains 324
Performance Monitoring 325
Summary 327
Chapter 9: Securing the Database Engine 329
Security Principles 329
The Principle of Least Privilege 329
The CIA Triad 330
Defense in Depth 331
Creating a Secure Configuration 332
New Security Features in SQL Server 2008 332
Operating System Security 333
Operating System Security and SQL Server 337
Surface Area Configuration 341
Endpoints 342
Typical Endpoint Configuration 342
Other Endpoints 344

Windows Authentication Changes in SQL Server 2008 344
Identity and Access Control 344
Server Principals/Logins 345
Credentials 354
Users 355
Schemas 358
Schema Example 359
Changing Schemas 362
User/Schema Separation 362
Changing the Schema Owner 363
INFORMATION_SCHEMA and sys Schemas 364
Securables and Object Permissions 364
Ownership Chaining 364
Cross-Database Ownership Chaining 365
Permission Context 366
EXECUTE AS Command 367
Troubleshooting Permissions Issues 369
Encryption 370
Setting Up an Encryption Methodology 370
Encrypting the Data 372
xviii
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xix
Contents
Creating a Helper Function Example 374
Column-Level Permissions 374
Transparent Data Encryption (TDE) 375
Extensible Key Management (EKM) 377
SQL S erver Audit 377
Creating an Audit 377
Creating and Enabling a Server Audit Specification 378

Creating and Enabling a Database Audit Specification 380
Summary 381
Chapter 10: Change Management 383
Creating Projects 383
Creating a Connection 384
Creating a Project Query 385
Policy-Based Management 386
Policy-Based Management Overview 386
Policy-Based Management Step By Step 387
Scripting Policy-Based Management 392
Policy-Based Management Implementation 394
DDL Trigger Syntax 397
Database Triggers 397
Server Triggers 401
Trigger Views 402
sqlcmd 403
Scripting Overview 403
Executing sqlcmd from the Command Prompt 403
Executing sqlcmd from Management Studio 405
Creating Change Scripts 407
Data Dude 408
PowerShell 408
Version Tables 410
Summary 412
Chapter 11: Configuring the Server for Optimal Performance 413
What Every DBA Needs to Know about Performance 414
The Performance Tuning Cycle 414
Defining Good Performance 415
Focus on What’s Most Important 415
What the Developer DBA Needs to Know about Performance 416

Users 417
SQL Statements 417
xix
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xx
Contents
Data 417
Robust Schema 417
What the Production DBA Needs to Know about Performance 418
Optimizing the S erver 419
Configuring Server Hardware 420
Windows Server System Reference Architecture 421
Windows Server Catalog 421
CPU 421
32-bit x86 Processors 421
x64 422
IA64 422
Choosing between x64 or IA64 422
Hyperthreading 423
Cache 424
Multi-Core 425
System Architecture 427
Memory 429
Physical Memory 429
Physical Address Space 429
Virtual Memory Manager 429
The Page File 430
Page Faults 430
Virtual Address Space 431
32-Bit System Memory Configuration 432
64-bit Systems 433

Memory Configuration Scenarios 434
I/O 436
Network 437
Disks 437
Storage Design 439
Designing a Storage System 441
Large Storage System Considerations: SAN Systems 445
Server Configuration 447
Fragmentation 452
Summary 453
Chapter 12: Optimizing SQL Server 2008 455
Application Optimization 455
Defining a Workload 455
System Harmony Is the Goal 456
xx
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxi
Contents
The Silent Killer: I/O Problems 456
SQL Server I/O Process Model 457
Database File Placement 457
tempdb Considerations 458
Table and Index Partitioning 461
Why Consider Partitioning? 461
Implementing Partitioning 462
Creating a Partition Function 463
Creating Filegroups 464
Creating a Partition Scheme 464
Creating Tables and Indexes 465
Data Compression 470
Row Compression 470

Page Compression 471
Estimating Space Savings 473
Monitoring Data Compression 475
Data Compression Considerations 475
Memory Considerations and Enhancements 476
Tuning SQL Server Memory 476
Windows 2008 Hot-Add CPU 479
Configuring SQL Server 2008 for Dynamic Memory on an X86 Platform 479
64-bit Versions of SQL Server 2008 482
Resource Governor 482
CPU Considerations 488
Data Locality 488
Cache Coherency 489
Affinity Mask 489
Max Degree of Parallelism (MAXDOP) 492
Affinity I/O Mask 492
Max Server Memory 493
Index Creation Memory Option 494
Minimum Memory per Query 494
Summary 495
Chapter 13: Monitoring Your SQL Server 497
The Goal of Monitoring 498
Determining Your Monitoring Objectives 498
Establishing a Baseline 498
Comparing Current Metrics to the Baseline 499
xxi
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxii
Contents
What’s New in Monitoring for SQL Server 2008 499
Data Collection 500

SQL Server Extended Events 500
Choosing the Appropriate Monitoring Tools 500
Performance Monitor 501
CPU Resource Counters 502
Isolating Processor Bottlenecks 503
Disk Activity 503
Memory Usage 510
Performance Monitoring Tools 513
Monitoring Events 514
The Default Trace 516
SQL Trace 516
Event Notifications 528
SQL Server Extended Event Notifications 531
Monitoring with Dynamic Management Views and Functions 539
What’s Going on Inside SQL Server 540
Viewing the Locking Information 543
Viewing Blocking Information 543
Index Usage in a Database 544
View Queries Waiting for Memory Grants 545
Connected User Information 546
Filegroup Free Space 546
Query Plan and Query Text for Currently Running Queries 547
Memory Usage 547
Monitoring Logs 548
Monitoring the SQL Server Error Log 548
Monitoring the Windows Event Logs 548
Management Data Warehouse 548
System Data Collection Sets 549
Viewing Data Collected By the System Data Collection Sets 549
Creating Your Own Data Collection Set 551

Examining the Data You Collected 553
Summary 554
Chapter 14: Performance Tuning T-SQL 555
Physical Query Processing 555
Compilation 559
Tools and Commands for Recompilation Scenarios 563
Parser and Algebrizer 564
Optimization 565
xxii
Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxiii
Contents
Tuning Process 570
Database I/O Information 570
Working with the Query Plan 571
Join Algorithms 579
Index Access Methods 582
Data Modification Query Plan 595
Query Processing Enhancements on Partitioned Tables and Indexes 600
Gathering Query Plans for Analysis with SQL Trace 602
Summary 603
Chapter 15: Indexing Your Database 605
Noteworthy Index-Related Features in SQL Server 605
What’s New for Indexes in SQL Server 2008 605
Index Features from SQL Server 2005 606
Sample Database 608
Partitioned Tables and Indexes 610
Why Use Partitioned Tables and Indexes? 610
Prerequisites for Partitioning 611
Creating Partitioned Tables 611
Filtered Indexes and Filtered Statistics 624

Index Maintenance 626
Monitoring Index Fragmentation 626
Cleaning Up Indexes 628
Database Tuning Advisor 630
Using the DTA to Tune Individual Queries 630
Too Many Indexes? 649
Tuning a Workload 651
Summary 652
Chapter 16: Replication 653
Replication Overview 653
Replication Types 654
Replication Components 655
Replication Enhancements in SQL Server 2008 656
Replication Models 657
Single Publisher, One or More Subscribers 657
Multiple Publishers, Single Subscriber 658
Multiple Publishers Also Subscribing 658
Updating Subscriber 660
Peer-to-peer 660
xxiii

×