Administration SQL Server 2008 · Server 2008, you’ll be able to confidently handle even the most...

30
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

Transcript of Administration SQL Server 2008 · Server 2008, you’ll be able to confidently handle even the most...

Page 1: Administration SQL Server 2008 · 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

ProfessionalMicrosoft®

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 forThis book is for experienced database administrators who are interested in learning best pratices for administering SQL Server 2008.

Enhance Your KnowledgeAdvance Your Career

Microsoft

®

SQ

L Server

® 2008A

dministration

Knight, Patel, Snyder, LoForte, Wort

Professional

subtitle

spine=1.728"

ProfessionalMicrosoft®

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 TMWrox Programmer to Programmer TM

Page 2: Administration SQL Server 2008 · 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

ProfessionalMicrosoft®

SQL Server® 2008 Administration

Enhance Your KnowledgeAdvance Your Career

Professional Microsoft SQL Server 2008 Integration Services978-0-470-24795-2This 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 Services978-0-470-24201-8This 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 Services978-0-470-24798-3Professional 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 Programming978-0-470-25702-9This 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 Administration978-0-470-24796-9A 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 Programming978-0-470-25701-2This 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 2008978-0-470-25703-6Beginning 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 Solutions978-0-470-38549-4Beginning 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™

InteractTake an active role online by participating in our P2P forums

Wrox Online LibraryHundreds 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 DemandPurchase individual book chapters in pdf format

Join the CommunitySign up for our free monthly newsletter at newsletter.wrox.com

BrowseReady 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 [email protected]

spine=1.728"

Page 3: Administration SQL Server 2008 · 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

Knight ffirs.tex V1 - 11/26/2012 4:58pm Page i

Professional Microsoft® SQL Server® 2008 Administration

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxixChapter 1: SQL Server 2008 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Chapter 2: SQL Server 2008 Installation Best Practices . . . . . . . . . . . . . . . . . . . . . . 35Chapter 3: Upgrading SQL Server 2008 Best Practices . . . . . . . . . . . . . . . . . . . . . . . 63Chapter 4: Managing and Troubleshooting the Database Engine . . . . . . . . . . . . . 97Chapter 5: Automating SQL Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129Chapter 6: Integration Services Administration and Performance Tuning. . . 175Chapter 7: Analysis Services Administration and Performance Tuning . . . . . 207Chapter 8: Administering the Development Features . . . . . . . . . . . . . . . . . . . . . . . 237Chapter 9: Securing the Database Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329Chapter 10: Change Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383Chapter 11: Configuring the Server for Optimal Performance . . . . . . . . . . . . . . . 413Chapter 12: Optimizing SQL Server 2008 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455Chapter 13: Monitoring Your SQL Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497Chapter 14: Performance Tuning T-SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555Chapter 15: Indexing Your Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605Chapter 16: Replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653Chapter 17: Database Mirroring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 683Chapter 18: Backup and Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731Chapter 19: SQL Server 2008 Log Shipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779Chapter 20: Clustering SQL Server 2008 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 839

Page 4: Administration SQL Server 2008 · 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

Knight ffirs.tex V1 - 11/26/2012 4:58pm Page ii

Page 5: Administration SQL Server 2008 · 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

Knight ffirs.tex V1 - 11/26/2012 4:58pm Page iii

ProfessionalMicrosoft®SQL Server®2008

Administration

Page 6: Administration SQL Server 2008 · 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

Knight ffirs.tex V1 - 11/26/2012 4:58pm Page iv

Page 7: Administration SQL Server 2008 · 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

Knight ffirs.tex V1 - 11/26/2012 4:58pm Page v

ProfessionalMicrosoft®SQL Server®2008

Administration

Brian KnightKetan Patel

Wayne SnyderRoss LoForteSteven Wort

Wiley Publishing, Inc.

Page 8: Administration SQL Server 2008 · 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

Knight ffirs.tex V1 - 11/26/2012 4:58pm Page vi

Professional Microsoft® SQL Server® 2008 AdministrationPublished byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.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

10 9 8 7 6 5 4 3 2 1

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 2008005.75’85 — dc22

2008037353

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by anymeans, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, orauthorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 RosewoodDrive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should beaddressed 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 warrantieswith 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 extendedby sales or promotional materials. The advice and strategies contained herein may not be suitable for everysituation. 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 personshould be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that anorganization or Website is referred to in this work as a citation and/or a potential source of further informationdoes not mean that the author or the publisher endorses the information the organization or Website may provideor recommendations it may make. Further, readers should be aware that Internet Websites listed in this work mayhave 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 theUnited 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 dressare trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and othercountries, and may not be used without written permission. Microsoft and SharePoint are registered trademarks ofMicrosoft Corporation in the United States and/or other countries. All other trademarks are the property of theirrespective 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 beavailable in electronic books.

Page 9: Administration SQL Server 2008 · 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

Knight fabout.tex V1 - 10/01/2008 4:21am Page vii

About the AuthorsBrian 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 SQLServer 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 webcastsat 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 atwww.pragmaticworks.com. Brian spends weekends practicing to be an amateur surgeon and proceedsfrom 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 theBusiness Intelligence Center of Excellence group at Microsoft. He has worked with SQL Server and otherMicrosoft technologies for nearly nine years. Ketan has also spoken at TechEd. He spends his spare timewith 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, softwaredesign, 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 editedmany SQL Server books, has SQL Training CDs with Learnkey, is president of PASS, the ProfessionalAssociation 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 IntelligenceCompany (www.mariner-usa.com).

Ross LoForte is a technical architect at the Microsoft Technology Center Chicago, focused on MicrosoftSQL 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 withthe Microsoft Technology Centers, and has led architecture design and proof-of-concept engagementsfor Microsoft’s largest and most strategic customers to design enterprise, mission-critical SQL Serversolutions. Ross is a SQL Server instructor at DePaul University in Chicago, and regularly presents atTechEd, SQL PASS, Gartner, TDWI, and other conferences. A published author, he has been active withthe Professional Association for SQL Server, the Chicago SQL Server Users Group, and the SQL Servercommunity for many years.

Steven Wort has been working with SQL Server for the past 14 years. He spent much of that time workingas a freelance application developer and database architect building VB and Web applications on SQLServer 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 overto the SQL Server Product group, spending a year working on SQL Server scalability, followed by a yearworking with the SQL Playback team. Two years ago Steven moved to the Windows division, where hestarted 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 beganworking with SQL Server in 1992 with version 4.2 and has used every version since. He specializes inhigh-availability and high-performance SQL systems. Recent projects include: system upgrades, SQLServer platform migrations, performance tuning, custom reporting solutions, and database strategyimplementations. Geoff is currently on the leadership team of the Atlanta area Microsoft Database Forum

Page 10: Administration SQL Server 2008 · 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

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 Associationfor SQL Server) Community Summit events. In addition, Geoff has been a Subject Matter Expert forMicrosoft Training Curriculum materials and has authored articles, white papers, and podcasts on SQLServer.

K. Brian Kelley (MCSE, Security+, CISA) is a systems and security architect for AgFirst Farm CreditBank. 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, authorof Start to Finish Guide to SQL Server Performance Monitoring and contributing author for How to Cheat atSecuring SQL Server 2005, is a regular columnist and blogger at SQLServerCentral.com focusing primarilyon SQL Server security. He is also a frequent contributor for SQL Server Standard Magazine. Brian is amember of the Professional Association of SQL Server (PASS) and the Information Systems Audit andControl Association (ISACA). He is also active in the Midlands PASS chapter, an official PASS chapterfor South Carolina.

viii

Page 11: Administration SQL Server 2008 · 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

Knight fcre.tex V1 - 10/01/2008 8:37am Page ix

CreditsExecutive EditorRobert Elliott

Development EditorSara Shlaer

Technical EditorJohn Mueller

Production EditorKathleen Wisor

Copy EditorLuann Rouff

Editorial ManagerMary Beth Wakefield

Production ManagerTim Tate

Vice President and Executive GroupPublisherRichard Swadley

Vice President and ExecutivePublisherJoseph B. Wikert

Project Coordinator, CoverLynsey Stanford

ProofreaderNancy CarrascoPublication Services, Inc.

IndexerRobert Swanson

Page 12: Administration SQL Server 2008 · 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

Knight fcre.tex V1 - 10/01/2008 8:37am Page x

Page 13: Administration SQL Server 2008 · 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

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 mytechnical writing. Thanks to my three children, Colton, Liam, and Camille, for allowing their daddyto be distracted sometimes with this book when they wanted to play. Thanks also to all the wonderfulco-authors, who truly made this book possible. Once again, I must thank the Pepsi-Cola Company forinventing 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 andinspiration in my life, and my wife, Sweety, for her invaluable support and understanding. I would like toacknowledge Brian Knight, the lead author, for providing me with a great opportunity to co-author thisbook. I would also like to acknowledge Sara Shlaer, the development editor, and John Mueller, technicaleditor — without them this book would not exist or contain the level of depth that it has. Last but not theleast, I want to thank B. J. Moore and Jim Walch, both general managers at Microsoft, for their invaluablesupport 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 theMicrosoft 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 withme over the past few months of writing. They have been infinitely patient and understanding while Ihave spent many long hours working. I must also thank everyone in the SQL Product Group who hashelped me with information about SQL Server 2008. Finally, I would like to thank everyone at WroxPress 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 theopportunity. You guys have been great mentors and I can’t thank you enough. — K. Brian Kelly

Page 14: Administration SQL Server 2008 · 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

Knight fack.tex V1 - 10/01/2008 4:22am Page xii

Page 15: Administration SQL Server 2008 · 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

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 1Production DBA 1Development DBA 2Business Intelligence DBA 3Hybrid DBA 3New Things You Need to Learn 4

SQL Server Architecture 5Transaction Log and Database Files 5SQL Native Client 6System Databases 7Schemas 9Synonyms 9Dynamic Management Views 10SQL Server 2008 Data Types 10

Editions of SQL Server 16Compact (32-bit only) 17SQL Express (32-bit only) 17Workgroup Edition (32-bit and 64-bit) 17Web Edition (32-bit and 64-bit) 17Standard Edition (32-bit and 64-bit) 17Enterprise, Evaluation, and Developer Editions (32-bit and 64-bit) 17Operating System 18Maximum Capacity of SQL Server 18Database Features By Edition 19Licensing 31

Summary 34

Chapter 2: SQL Server 2008 Installation Best Practices 35

Planning the System 35Hardware Options 36Software and Install Options 40

Page 16: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xiv

Contents

Installing SQL Server 45Side-By-Side, Upgrade, and New Installs 45Scripted Installation 46Remote Installation 47Local Installation 47Where Are the Sample Databases? 50

Installing Analysis Services 51Burning in the System 52Post-Install Configuration 52

SQL Server Configuration Manager 53SQL Server Management Studio 53tempdb 54Back It Up 56

Uninstalling SQL Server 57Uninstalling Reporting Services 57Uninstalling Analysis Services 58Uninstalling the SQL Server Database Engine 58

Common Installation Issues 59Installing Client Tools from a Network Share 59Admin Tools Not Installed by Default on Remote Cluster Nodes 60Minimum Configuration Warning 60

Troubleshooting a Failed Install 60Summary 61

Chapter 3: Upgrading SQL Server 2008 Best Practices 63

Why Upgrade to SQL Server 2008? 63Risk Mitigation — The Microsoft Contribution 64Independent Software Vendors and SQL Community Contributions 65

Upgrading to SQL Server 2008 65In-Place Upgrading 66Side-by-Side Upgrade 67In-Place Upgrade versus Side-By-Side Upgrade Considerations 67

Pre-Upgrade Checks 69SQL Server Upgrade Advisor 69Installing the SQL Server 2008 Upgrade Advisor 69Using the Upgrade Advisor 70Scripting the Upgrade Advisor 72Resolving Upgrade Issues 73SQL Server 2008 Upgrade Assistant 75

Backward Compatibility 77Unsupported and Discontinued Features 77SQL Server 2008 Deprecated Database Features 78Other SQL Server 2008 Changes Affecting Behavior 78

xiv

Page 17: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xv

Contents

SQL Server Component Considerations 79Upgrading Full-Text Catalog to SQL Server 2008 79Upgrading Reporting Services 80Upgrading Analysis Services 80Upgrading DTS to SQL Server 2008 Integration Services (SSIS) 81Log Shipping 88Failover Clustering and Data Mirroring 88Upgrading to 64-bit 88

Post-Upgrade Checks 89Poor Query Performance After Upgrade 89Updating Usage Counters 90SQL Server Configuration Manager 91Policy-Based Management 91

Summary 96

Chapter 4: Managing and Troubleshooting the Database Engine 97

Configuration Tools 97SQL Server Configuration Manager 97Dedicated Administrator Connection 99Configuration Servers and Server Groups 100Startup Parameters 101Startup Stored Procedures 104Rebuilding the System Databases 105

Management Studio 106Reports 106Configuring SQL Server 108Filtering Objects 112Error Logs 113Activity Monitor 114Monitoring Processes in T-SQL 118

Trace Flags 120Getting Help from Support 124

SQLDumper.exe 124SQLDiag.exe 125

Summary 127

Chapter 5: Automating SQL Server 129

Maintenance Plans 129Maintenance Plan Wizard 130Maintenance Plan Designer 132

SQL Server Agent 136Automation Components 137SQL Server Agent Security 151

xv

Page 18: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xvi

Contents

Configuring SQL Server Agent 156Database Mail 160Multiserver Administration 166

Summary 172

Chapter 6: Integration Services Administration and Performance Tuning 175

A Tour of Integration Services 175Integration Services Uses 176The Four Main Parts of Integration Services 177Project Management and Change Control 179

Administration of the Integration Services Service 179An Overview of the Integration Services Service 179Configuration 180Event Logs 185Monitoring Activity 187

Administration of Integration Services Packages 187An Overview of Integration Services Packages 187Creating Packages 188Management 191Deployment 194Execution and Scheduling 199

Applying Security to Integration Services 203An Overview of Integration Services Security 203Securing Packages 203Saving Packages 205Running Packages 205Package Resources 205Digital Signatures 206

Summary 206

Chapter 7: Analysis Services Administration and Performance Tuning 207

Tour of Analysis Services 207Unified Dimensional Model Components 208Analysis Services Architectural Components 209

Administering Analysis Services Server 210Required Services 212Analysis Services Scripting Language 212

Administering Analysis Services Databases 214Deploying Analysis Services Databases 214Processing Analysis Services Objects 217Backing Up and Restoring Analysis Services Databases 219Synchronizing Analysis Services Databases 222

xvi

Page 19: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xvii

Contents

Analysis Services Performance Monitoring and Tuning 223Monitoring Analysis Services Events Using SQL Profiler 223Creating Traces for Replay 224Using Flight Recorder for After-the-Fact Analysis 226

Management of Analysis Services Storage 227Storage Modes 227Partition Configuration 227Designing Aggregations 228

Applying Security to Analysis Services 233Server Role 233Database Role 233Database Role Permissions 234

Summary 236

Chapter 8: Administering the Development Features 237

Service Broker 237Service Broker Architecture 238Service Broker Examples 246Activation 260Conversation Groups 265

Security Considerations for Service Broker 267Transport Security 267Routing 271Dialog Security 275

Conversation Priorities 279Setting Conversation Priorities 279Reviewing Conversation Priorities 288

Administering Service Broker 288Installing Service Broker Application 289Setting Permission on Service Broker Objects 290Managing Service Broker Queues 292Poison Message Handling 293Moving Service Broker Applications 295Copying Service Broker Applications 296Replacing Expired Certificates 297Troubleshooting Service Broker Applications 297Performance Tuning Service Broker 307

Introduction to CLR Integration 308SQL Server As .NET Runtime Host 308Application Domains 309T-SQL versus CLR 310Extended Stored Procedures versus CLR 310

xvii

Page 20: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xviii

Contents

Enabling CLR Integration 311Creating the CLR Assembly 312Deploying the Assembly 315Cataloging Objects 321Application Domains 324Performance Monitoring 325

Summary 327

Chapter 9: Securing the Database Engine 329

Security Principles 329The Principle of Least Privilege 329The CIA Triad 330Defense in Depth 331

Creating a Secure Configuration 332New Security Features in SQL Server 2008 332Operating System Security 333Operating System Security and SQL Server 337

Surface Area Configuration 341Endpoints 342

Typical Endpoint Configuration 342Other Endpoints 344Windows Authentication Changes in SQL Server 2008 344

Identity and Access Control 344Server Principals/Logins 345Credentials 354Users 355

Schemas 358Schema Example 359Changing Schemas 362User/Schema Separation 362Changing the Schema Owner 363INFORMATION_SCHEMA and sys Schemas 364

Securables and Object Permissions 364Ownership Chaining 364Cross-Database Ownership Chaining 365Permission Context 366EXECUTE AS Command 367Troubleshooting Permissions Issues 369

Encryption 370Setting Up an Encryption Methodology 370Encrypting the Data 372

xviii

Page 21: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xix

Contents

Creating a Helper Function Example 374Column-Level Permissions 374Transparent Data Encryption (TDE) 375Extensible Key Management (EKM) 377

SQL Server Audit 377Creating an Audit 377Creating and Enabling a Server Audit Specification 378Creating and Enabling a Database Audit Specification 380

Summary 381

Chapter 10: Change Management 383

Creating Projects 383Creating a Connection 384Creating a Project Query 385

Policy-Based Management 386Policy-Based Management Overview 386Policy-Based Management Step By Step 387Scripting Policy-Based Management 392Policy-Based Management Implementation 394DDL Trigger Syntax 397Database Triggers 397Server Triggers 401

Trigger Views 402sqlcmd 403

Scripting Overview 403Executing sqlcmd from the Command Prompt 403Executing sqlcmd from Management Studio 405

Creating Change Scripts 407Data Dude 408PowerShell 408Version Tables 410

Summary 412

Chapter 11: Configuring the Server for Optimal Performance 413

What Every DBA Needs to Know about Performance 414The Performance Tuning Cycle 414Defining Good Performance 415Focus on What’s Most Important 415

What the Developer DBA Needs to Know about Performance 416Users 417SQL Statements 417

xix

Page 22: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xx

Contents

Data 417Robust Schema 417

What the Production DBA Needs to Know about Performance 418Optimizing the Server 419Configuring Server Hardware 420

Windows Server System Reference Architecture 421Windows Server Catalog 421

CPU 42132-bit x86 Processors 421x64 422IA64 422Choosing between x64 or IA64 422Hyperthreading 423Cache 424Multi-Core 425System Architecture 427

Memory 429Physical Memory 429Physical Address Space 429Virtual Memory Manager 429The Page File 430Page Faults 430Virtual Address Space 43132-Bit System Memory Configuration 43264-bit Systems 433Memory Configuration Scenarios 434

I/O 436Network 437Disks 437Storage Design 439Designing a Storage System 441Large Storage System Considerations: SAN Systems 445Server Configuration 447Fragmentation 452

Summary 453

Chapter 12: Optimizing SQL Server 2008 455

Application Optimization 455Defining a Workload 455System Harmony Is the Goal 456

xx

Page 23: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxi

Contents

The Silent Killer: I/O Problems 456SQL Server I/O Process Model 457Database File Placement 457tempdb Considerations 458

Table and Index Partitioning 461Why Consider Partitioning? 461Implementing Partitioning 462Creating a Partition Function 463Creating Filegroups 464Creating a Partition Scheme 464Creating Tables and Indexes 465

Data Compression 470Row Compression 470Page Compression 471Estimating Space Savings 473Monitoring Data Compression 475Data Compression Considerations 475

Memory Considerations and Enhancements 476Tuning SQL Server Memory 476Windows 2008 Hot-Add CPU 479Configuring SQL Server 2008 for Dynamic Memory on an X86 Platform 47964-bit Versions of SQL Server 2008 482Resource Governor 482

CPU Considerations 488Data Locality 488Cache Coherency 489Affinity Mask 489Max Degree of Parallelism (MAXDOP) 492Affinity I/O Mask 492Max Server Memory 493Index Creation Memory Option 494Minimum Memory per Query 494

Summary 495

Chapter 13: Monitoring Your SQL Server 497

The Goal of Monitoring 498Determining Your Monitoring Objectives 498Establishing a Baseline 498Comparing Current Metrics to the Baseline 499

xxi

Page 24: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxii

Contents

What’s New in Monitoring for SQL Server 2008 499Data Collection 500SQL Server Extended Events 500

Choosing the Appropriate Monitoring Tools 500Performance Monitor 501

CPU Resource Counters 502Isolating Processor Bottlenecks 503Disk Activity 503Memory Usage 510Performance Monitoring Tools 513

Monitoring Events 514The Default Trace 516SQL Trace 516Event Notifications 528SQL Server Extended Event Notifications 531

Monitoring with Dynamic Management Views and Functions 539What’s Going on Inside SQL Server 540Viewing the Locking Information 543Viewing Blocking Information 543Index Usage in a Database 544View Queries Waiting for Memory Grants 545Connected User Information 546Filegroup Free Space 546Query Plan and Query Text for Currently Running Queries 547Memory Usage 547

Monitoring Logs 548Monitoring the SQL Server Error Log 548Monitoring the Windows Event Logs 548

Management Data Warehouse 548System Data Collection Sets 549Viewing Data Collected By the System Data Collection Sets 549Creating Your Own Data Collection Set 551Examining the Data You Collected 553

Summary 554

Chapter 14: Performance Tuning T-SQL 555

Physical Query Processing 555Compilation 559Tools and Commands for Recompilation Scenarios 563Parser and Algebrizer 564Optimization 565

xxii

Page 25: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxiii

Contents

Tuning Process 570Database I/O Information 570Working with the Query Plan 571Join Algorithms 579Index Access Methods 582Data Modification Query Plan 595Query Processing Enhancements on Partitioned Tables and Indexes 600Gathering Query Plans for Analysis with SQL Trace 602

Summary 603

Chapter 15: Indexing Your Database 605

Noteworthy Index-Related Features in SQL Server 605What’s New for Indexes in SQL Server 2008 605Index Features from SQL Server 2005 606

Sample Database 608Partitioned Tables and Indexes 610

Why Use Partitioned Tables and Indexes? 610Prerequisites for Partitioning 611Creating Partitioned Tables 611

Filtered Indexes and Filtered Statistics 624Index Maintenance 626

Monitoring Index Fragmentation 626Cleaning Up Indexes 628

Database Tuning Advisor 630Using the DTA to Tune Individual Queries 630Too Many Indexes? 649Tuning a Workload 651

Summary 652

Chapter 16: Replication 653

Replication Overview 653Replication Types 654Replication Components 655Replication Enhancements in SQL Server 2008 656

Replication Models 657Single Publisher, One or More Subscribers 657Multiple Publishers, Single Subscriber 658Multiple Publishers Also Subscribing 658Updating Subscriber 660Peer-to-peer 660

xxiii

Page 26: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxiv

Contents

Implementing Replication 661The Setup 662Setting Up Distribution 663Implementing Snapshot Replication 666Implementing Transactional and Merge Replication 674

Peer-to-Peer Replication 675Scripting Replication 679Monitoring Replication 679

Replication Monitor 679Performance Monitor 679Replication DMVs 681sp_replcounters 682

Summary 682

Chapter 17: Database Mirroring 683

Overview of Database Mirroring 683Operating Modes of Database Mirroring 685Database Mirroring Example 687Database Mirroring and SQL Server 2008 Editions 697Database Mirroring Catalog Views 698Database Mirroring Role Change 700Database Availability Scenarios 706

Monitoring Database Mirroring 709Monitoring Using System Monitor 709Monitoring Using Database Mirroring Monitor 711Setting Thresholds on Counters and Sending Alerts 714Monitoring Using SQL Profiler 716

Troubleshooting Database Mirroring 716Troubleshooting Setup Errors 716Troubleshooting Runtime Errors 717Automatic Page Repair 718

Preparing the Mirror Server for Failover 719Hardware, Software, and Server Configuration 719Database Availability During Planned Downtime 720SQL Job Configuration on the Mirror 722Database TRUSTWORTHY Bit on the Mirror 722Client Redirection to the Mirror 722

Mirroring Multiple Databases 723Database Mirroring and Other High-Availability Solutions 724

Database Mirroring and Clustering 724Database Mirroring and Transactional Replication 725Database Mirroring and Log Shipping 725

xxiv

Page 27: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxv

Contents

Mirroring Event Listener Setup 725Database Snapshots 729Summary 730

Chapter 18: Backup and Recovery 731

Types of Failure 731Hardware Failure 732User Error 732Application Failure 732Software Failure 732Too Much Privilege 733Local Disasters 733

Making Plans 733Backup/Recovery Plan 734Maintaining the Plan 738

Overview of Backup and Restore 739How Backup Works 739Backup Compression 742How Restore Works 743Comparing Recovery Models 744Choosing a Model 745Switching Recovery Models 746Verifying the Backup Images 747Backing Up History Tables 749Permissions Required for Backup and Restore 750Backing Up System Databases 750Full-text Backup 751

Planning for Recovery 752Recoverability Requirements 752Data Usage Patterns 753Maintenance Time Window 753Other High-Availability Solutions 755

Developing and Executing a Backup Plan 755Using SQL Server 2008 Management Studio 755Database Maintenance Plans 760Using Transact-SQL Backup Commands 762

Managing Backups 764Backup and Restore Performance 764Performing Recovery 765

Restore Process 765SQL Server Management Studio Restore 769

xxv

Page 28: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxvi

Contents

T-SQL Restore Command 772Restoring System Databases 773

Archiving Data 775SQL Server 2008 Table Partitioning 775Partitioned View 776

Disaster Recovery Planning 776Summary 778

Chapter 19: SQL Server 2008 Log Shipping 779

Log Shipping Deployment Scenarios 779Log Shipping to Create a Warm Standby Server 780Log Shipping As a Disaster Recovery Solution 780Log Shipping As a Report Database Solution 781

Log-Shipping Architecture 782Primary Server 782Secondary Server 783Monitor Server 783

Log Shipping Process 783System Requirements 784

Network 784Identical Capacity Servers 784Storage 784Monitor Server 785Software 785

Deploying Log Shipping 785Initial Configuration 785Deploying with Management Studio 786Deploying with T-SQL Commands 790

Monitoring and Troubleshooting 791Monitoring with Management Studio 792Monitoring with Stored Procedures 793Troubleshooting Approach 793

Managing Changing Roles 794Synchronizing Dependencies 794Switching Roles from the Primary to Secondary Servers 796Switching Between Primary and Secondary Roles 798Redirecting Clients to Connect to the Secondary Server 799

xxvi

Page 29: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxvii

Contents

Database Backup Plan 800Integrating Log Shipping with Other High-Availability Solutions 800

SQL Server 2008 Data Mirroring 801Windows Failover Clustering 801SQL Server 2008 Replication 801

Removing Log Shipping 802Removing Log Shipping with Management Studio 802Removing Log Shipping with T-SQL Commands 802

Log-Shipping Performance 803Upgrading to SQL Server 2008 Log Shipping 803

Minimum Downtime Approach 803With Downtime Approach 804Deploy Log Shipping Approach 804

Summary 804

Chapter 20: Clustering SQL Server 2008 807

Clustering and Your Organization 808What Clustering Can Do 808What Clustering Cannot Do 809Choosing SQL Server 2008 Clustering for the Right Reasons 810Alternatives to Clustering 810

Clustering: The Big Picture 812How Clustering Works 812Clustering Options 814

Upgrading SQL Server Clustering 817Don’t Upgrade 817Upgrading Your SQL Server 2008 Cluster In-Place 817Rebuilding Your Cluster from Scratch 817Backout Plan 819Which Upgrade Option Is Best? 819

Getting Prepared for Clustering 819Preparing the Infrastructure 820Preparing the Hardware 821

Clustering Windows Server 2008 823Before Installing Windows 2008 Clustering 823Installing Windows Server 2008 Clustering 824Configuring Windows Server 2008 for Clustering 827

xxvii

Page 30: Administration SQL Server 2008 · 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

Knight ftoc.tex V1 - 10/01/2008 4:36am Page xxviii

Contents

Clustering SQL Server 2008 828Clustering SQL Server 828Installing the Service Pack and Hot Fixes 831Test, Test, and Test Again 831

Maintaining the Cluster 833Troubleshooting Cluster Problems 834

How to Approach Clustering Troubleshooting 834Doing It Right the First Time 835Gathering Information 835Resolving Problems 836Working with Microsoft 836

Summary 837

Index 839

xxviii