SQL Server 2008 Administration Real World Skills for ITP Certification and Beyond Tom Carpenter WILEY Wiley Publishing, Inc.
Contents Introduction xxi Part i Introducing SQL Server 2008 1 Chapter 1 Understanding SQL Server's Role 3 What Is Information Technology? 4 The Importance of IT 4 The Components of IT 6 Introduction to Databases 7 Types of Databases 8 Weighing the Benefits of Using a Local or Server-Based Database 11 Important Database Terms 16 Database Servers and Applications 18 Database Application Types 18 SQL Server's Role 20 New Features Since SQL Server 2005 21 New Features Since SQL Server 2000 25 Core Features of SQL Server 34 SQL Server Roles 35 Summary 39 Chapter Essentials 39 Chapter 2 Installing SQL Server 2008 41 Installation Planning 42 SQL Server 2008 Architecture 42 Installation Planning Process 52 Managing Permissions 56 Installing a Default Instance 58 SQL Server Installation Center Tasks 59 Installation 60 Installing Named Instances 68 Installing to a Cluster 71 Installing Extra Features 72 Upgrading from Previous Versions 72 Handling Upgrades 73 Understanding Migrations 74 Removing an Installation 74 Summary 75 Chapter Essentials 75
xii Contents Chapter 3 Working with the Administration Tools 77 SQL Server Configuration Manager 78 Overview of the SSCM 79 Performing Common SSCM Tasks 81 SQL Server Management Studio (SSMS) 86 Overview of the SSMS 86 Performing Common SSMS Tasks 89 SQL Server Business Intelligence Development Studio 96 Overview of BIDS 96 Performing Common BIDS Tasks 97 SQL Server Profiler 108 Books Online 112 Windows Server Administration for the DBA 113 User Account Management 114 File System Management 114 Network Configuration Administration 116 Summary 122 Chapter Essentials 122 Chapter 4 SQL Server Command-Line Administration 123 Introducing the Command Prompt 124 General Command-Prompt Options 126 Font Settings 127 Screen Layout 128 Color Choices 129 General Commands 129 Directory and Folder Navigation 130 Directory and Folder Listing 131 Screen Management 135 Displaying Information 136 Redirecting Output 140 Administrative Commands 142 Batch Files 149 Using Logic (IF and GOTO) 149 Passing Data 151 Including Comments 152 Mastering SQLCMD 156 Introducing Windows PowerShell 159 Using SQL Server PowerShell Extensions 160 Windows Scripting Host 163 Summary 164 Chapter Essentials 164
Contents xiii Part il Designing Database Solutions 167 Chapter 5 Database Concepts and Terminology 169 Relational Database Theory 170 Data 171 Information 171 Tables 172 Table Components 172 Relationship Types 176 Database Design Processes 180 Systems Development Lifecycle (SDLC) 181 Database Lifecycle (DBLC) 182 Business, User, Model (BUM) 183 Project Management for the DBA 187 The Define Phase 188 The Design Phase 190 The Deliver Phase 191 The Determine Phase 191 Summary 192 Chapter Essentials 192 Chapter 6 ERD and Capacity Planning 195 Planning a Database 196 User Surveys 197 Evaluating Business Processes 198 Developing Use Cases 200 Understanding Entity Relationship Diagramming 201 Building an ERD 203 Creating an ERD in Visio 204 Creating an ERD in OSA 210 Capacity Planning 217 Summary 222 Chapter Essentials 223 Chapter 7 Normalization: Enough Is Enough 225 Normalization Defined 226 Normal Forms 228 First Normal Form 228 Second Normal Form 232 Third Normal Form 233 Really, Really Normal Forms 234 Normalizing a Database 237 Building a INF Table from the Excel Worksheet 238 Ensuring Data Is in 2NF and 3NF 239 Denormalizing a Database 240
xiv Contents Designing for Performance 241 Designing for Availability 242 Designing for Security 243 Summary 243 Chapter Essentials 244 Part ill Implementing Database Solutions 245 Chapter 8 Creating SQL Server Databases 247 SQL Server Databases 248 System Databases 249 User Databases 253 Database Storage 254 Database Data Files 254 Database Filegroups 255 Transaction Logs 256 Database Options and Properties 257 Autogrowth 258 Recovery Model 259 Compatibility Level 261 Auto Shrink 262 Restrict Access 263 More Database Properties 264 Creating Databases in the GUI 267 Creating Databases with T-SQL 269 Creating Databases with PowerShell 273 Attaching and Detaching Databases 274 Database Snapshots 277 Creating Snapshots 277 Reverting to Snapshots 279 Summary 280 Chapter Essentials 280 Chapter 9 Creating Tables 283 Data Types 284 Data Type Categories 285 Collations 290 Configuring Server Instance Collations 291 Configuring Database Collations 292 Configuring Column Collations 292 Creating Tables 295 Creating Tables with the Table Designer 295 Creating Tables with T-SQL 302
Contents xv Data Partitioning 304 Vertical and Horizontal Partitioning 304 Data Partitioning with Functions and Schemes 305 Summary 307 Chapter Essentials 307 Chapter 10 Indexes and Views 309 Understanding Indexes 310 Indexes Defined 311 Index Types 315 Creating Basic Indexes 318 Creating a Clustered Index 319 Creating a Nonclustered Index 321 Creating Advanced Indexes 325 Creating a Covering Index 325 Creating a Filtered Index 327 Managing Indexes 330 Dropping an Index 330 Disabling and Enabling Indexes 330 Understanding Index Fragmentation 333 Understanding Views 335 Creating Views 336 Summary 338 Chapter Essentials 339 Chapter 11 Triggers and Stored Procedures 341 Triggers Defined 342 How Triggers Differ from Stored Procedures 343 Types of Triggers 344 Recursive and Nested Triggers 345 Using Triggers 345 Creating Triggers 348 Understanding Stored Procedures 353 Creating Stored Procedures 355 Summary 356 Chapter Essentials 356 Chapter 12 Implementing Advanced Features 359 Understanding and Installing Analysis Services 361 Analysis Services Tools 361 Analysis Services Optional Components 363 Installing and Configuring Analysis Services 364
xvi Contents Understanding Integration Services 368 Installing and Configuring Integration Services 368 Creating a Basic Integration Services Package 372 Troubleshooting and Debugging an SSIS Package 379 Scheduling Your Package to Run Automatically 380 Security Protection Levels 383 Understanding and Installing Reporting Services 385 Implementing Database Mail 390 Configuring Full-Text Indexing 394 Summary 396 Chapter Essentials 397 Part IV Administration and Maintenance 399 Chapter 13 Creating Jobs, Operators, and Alerts 401 Standardize, Automate, and Update 403 Understanding SQL Server Jobs 404 Job Steps 405 Job Configuration Properties 406 Typical Jobs 414 Creating T-SQL Jobs 417 Creating SSIS Jobs 421 Creating Windows Command Jobs 428 Creating and Using Operators 432 Creating and Using Alerts 434 Using WSUS for SQL Server 200 8 439 Summary 440 Chapter Essentials 440 Chapter 14 Performance Monitoring and Tuning 443 Performance Tuning Principles 444 Why Performance Tuning Matters 444 Common Performance Tuning Myths 446 Performance and Troubleshooting Tools 448 Blocks, Locks, and Deadlocks 449 Understanding Locks 450 Lock Types 450 Granularity of Locks 451 Lock Isolation Levels 451 Blocks and Deadlocks 451 SQL Server Profiler 455 Database Engine Tuning Advisor 457 Creating a DTA Workload File 458 Analyzing Your Workload File 459 Applying DTA Recommendations 461
Contents xvii Performance Monitoring with System Monitor 463 Installing the System Monitor 463 Viewing Live Performance Data 464 Logging Counters in Windows Server 2003 466 Data Collection in Windows Server 2008 467 Using the New Resource Governor 471 Performance Studio 472 Advanced Monitoring Tools 475 Dynamic Management Views (DMVs) 476 DBCC 477 Resource Monitor 479 Summary 482 Chapter Essentials 482 Chapter 15 Policy-Based Management 485 Policy-Based Management (PBM) 486 PBM Components 488 Creating Conditions 502 Creating Policies 504 Evaluating Policies 509 Centralized Server Management 509 Major Benefits and Requirements 509 Creating a Centralized Management Server 510 Registering Subscriber Servers 510 Standardizing with PBM and CMS 514 Standardizing 514 Automating 515 Updating 517 Summary 518 Chapter Essentials 518 Chapter 16 Backup and Restoration 519 Backing Up a Database 520 Creating a Backup Plan 521 Choosing a Recovery Model 524 Using the Different Backup Types 528 Working with Backup Devices and Files 534 Compressing Backups 536 Performing File and Filegroup Backups 537 Back Up System Databases 538 Restore a Database 538 Choosing a Restore Method 539 Restoring to a Point in Time 539 Restoring to the Point of Failure 541 Restoring System Databases 542
xviii Contents Back Up the Environment 543 Built-in Backup Tools 543 Imaging and Third-Party Tools 544 Summary 545 Chapter Essentials 546 Part V SQL Server Security 547 Chapter 17 Security Threats and Principles 549 Security Defined 550 How to Classify Data for Security Purposes 553 Security in Theory 555 Security in the Real World 556 Security Threats 557 Threats, Vulnerabilities, and Exploits Defined 557 Attack Point One: Windows Server 559 Attack Point Two: SQL Server 564 Attack Point Three: the Network 565 Attack Point Four: the Client 569 Cracking Examples 572 Security Principles 584 Start with Good Design 585 Trust, but Monitor 586 Defense-in-Depth 588 Least Privilege 588 Summary 589 Chapter Essentials 590 Chapter 18 Authentication and Encryption 591 Understanding Authentication 592 Credentials 594 Common Authentication Methods 596 Regulatory Compliance 598 SQL Server Authentication Methods 602 Logins, Users, and Roles 603 Configuring the Authentication Mode 603 Creating and Managing Principals and Roles 605 Creating Database Users 619 Understanding Encryption 619 SQL Server Encryption Solutions 620 Implementing Application-Level Encryption 622 Implementing Transparent Encryption 624 Summary 625 Chapter Essentials 626
Contents xix Chapter 19 Security Best Practices 627 Establishing Baselines 628 Working with Security Templates 629 Analyzing a Server's Security Settings 636 Using the Security Configuration Wizard 638 Implementing Least Privilege 643 Permissions and Authorization 643 Ownership Chains 649 Credentials 650 Auditing SQL Server Activity 652 Using Audits 652 Notifications 656 DDL Triggers 657 Logon Triggers 657 Configuring the Surface Area 658 SP_Configure for Surface Area Management 659 Policy-Based Management Surface Area Options 660 Understanding Common Criteria and C2 663 GRC 663 C2 Compliance 664 Common Criteria 667 Summary 668 Chapter Essentials 669 Part VI High Availability and Data Distribution 671 Chapter 20 SQL Server Faiiover Clustering 673 Understanding Windows Faiiover Clustering Service 674 Implementing a Windows Cluster 677 Faiiover Clustering Components 677 The Faiiover Clustering Installation Process 680 Installing SQL Server 2008 to a Cluster 690 Monitoring and Managing a SQL Server Cluster 690 Service Packs and Update Management 691 Faiiover Management 691 Cluster Troubleshooting 692 Summary 692 Chapter Essentials 693
xx Contents Chapter 21 Database Mirroring and Snapshots 695 RAID-Based Data Redundancy 696 Using Database Mirroring 699 Database Mirroring Components 700 Understanding Mirror Operating Modes 701 Planning for Role Switching 701 Implementing Database Mirroring 702 Understanding Log Shipping 706 Inside the Log-Shipping Process 706 Configuring Log Shipping and Monitoring 708 Implementing Database Snapshots 710 Database Snapshot Functionality 711 Implementing a Snapshot 712 Querying a Snapshot 712 Reverting to a Snapshot 712 Summary 713 Chapter Essentials 713 Chapter 22 Implementing Replication 715 SQL Server Replication 716 SQL Server Replication Roles and Concepts 717 Replication Types 717 Replication Models 719 Configuring a Publisher and Distributor 720 Configuring a Subscriber 727 Monitoring Replication 729 Replication Performance 729 Replication Recovery 730 Importing and Exporting Data 730 Using BCP 731 Bulk Insert Commands 732 Using SQL Server Integration Services (SSIS) 734 Summary 736 Chapter Essentials 736 Appendix A Microsoft's Certification Program 737 Appendix B About the Companion CD 745 Glossary 749 Index 757