EXAM 70-462 Administering Microsoft SQL Server 2012...
Transcript of EXAM 70-462 Administering Microsoft SQL Server 2012...
70-462
Training KitEX
AM
EXAM 70-462
1
2
EXAM PREP GUIDE
Your 2-in-1 Self-Paced Training Kit
EX AM
70-462
Administering M
icrosoft®
SQL Server
® 2012 Databases
Training Kit
For complete information on Microsoft Certifications, visit: microsoft.com/learning/certification
Microsoft® Certified Solutions Associate The new MCSA certifications validate the core technical skills required to build a sustainable career in IT. MCSA opens the door to multiple career paths and is a requirement for MCSE certifications.Exam 70-642 is one of three required exams for MCSA: Windows Server 2008 certification. For a limited time, it is also valid for MCTS certification, which will be retired.
For system requirements, see the Introduction.
Your kit includes:· 15% exam discount from Microsoft. Offer expires 12/31/15. Details inside.
· Official self-paced study guide.
· Practice tests with multiple, customizable testing options and a learning plan based on your results.
· 200+ practice and review questions.
· Case scenarios, exercises, and best practices.
· Fully searchable eBook of this guide.
About the AuthorsTony Northrup, MCITP, MCPD, MCSE, CISSP, has written 20+ books covering Windows system administration and development, including several Microsoft Press® Training Kits and Windows Server 2008 Networking and Network Access Protection (NAP).
J.C. Mackin, MCITP, MCTS, MCSE, MCT, is a writer, editor, and trainer who’s worked with Windows networking technologies for 10+ years. He has written several Training Kits, including for Exams 70-622, 70-643, and 70-685.
Administering Microsoft® SQL Server® 2012 Databases
Fully updated for Windows Server 2008 R2! Ace your preparation for the skills measured by Exam 70-642—and on the job. Work at your own pace through a series of lessons and reviews that fully cover each exam objective. Then, reinforce what you’ve learned by applying your knowledge to real-world case scenarios and practice exercises. This official Microsoft study guide is designed to help make the most of your study time.
Maximize your performance on the exam by learning to:
• Configure IPv4 and IPv6 addressing• Deploy and configure DHCP servers, DNS servers, and DNS zones• Implement IPsec, Windows® Firewall, and Network Access Protection (NAP)• Plan and manage Windows Server Update Services• Manage file and print services in Windows Server 2008 R2• Enable remote and wireless access, including DirectAccess• Monitor and troubleshoot network performance
Assess your skills with practice tests on CD. You can work through hundreds of questions using multiple testing modes to meet your specific learning needs. You get detailed explanations for right and wrong answers —including a customized learning path that describes how and where to focus your studies.
PRACTICE TESTS
Orin Thomas Peter Ward boB Taylor
ISBN: 978-0-7356-6607-8
Certification/ Windows Server
U.S.A. $69.99Canada $80.99
[Recommended ]
microsoft.com/mspressPr
actice tests on CDPr
actice tests on CD
Administering Microsoft SQL Server 2012 Databases
®
®
spine = 1.47”
Cyan Magenta Yellow Black
Exam 70-462: Administering Microsoft SQL Server 2012 Databases
OBJECTIVE CHAPTER LESSON
INSTALL AND CONFIGURE (19 PERCENT)
Plan installation. 1 1
Install SQL Server and related services. 1 2
Implement a migration strategy. 4 1
Configure additional SQL Server components. 3 1
Manage SQL Server Agent. 11 1
MAINTAIN INSTANCES AND DATABASES (17 PERCENT)
Manage and configure databases. 3 3
Configure SQL Server instances. 2 1
Implement a SQL Server clustered instance. 8 1
Manage SQL Server instances. 2 2
OPTIMIZE AND TROUBLESHOOT (14 PERCENT)
Identify and resolve concurrency problems. 10 2
Collect and analyze troubleshooting data. 9 1–6
Audit SQL Server instances. 6 3
MANAGE DATA (20 PERCENT)
Configure and maintain a back up strategy. 11 2
Restore databases. 11 3
Implement and maintain indexes. 10 1
Import and export data. 4 2
IMPLEMENT SECURITY (18 PERCENT)
Manage logins and server roles. 5 1
Manage database permissions. 6 1
Manage users and database roles. 5 2
Troubleshoot security. 6 2
IMPLEMENT HIGH AVAILABILITY (12 PERCENT)
Implement AlwaysOn. 8 2
Implement database mirroring. 7 1
Implement replication. 7 2
Exam Objectives The exam objectives listed here are current as of this book’s publication date. Exam objectives are subject to change at any time without prior notice and at Microsoft’s sole discretion. Please visit the Microsoft Learning website for the most current listing of exam objectives: http://www.microsoft.com/learning/en/us/exams/70-462.mspx.
ContentsIntroduction xviiSystem Requirements xviiHardware Requirements xviiiSoftware Requirements xviiiPractice Setup Instructions xixPrepare a Computer to Function as a Windows Server 2008 R2 Domain Controller xixPrepare AD DS xxPrepare a Member Server and Join It to the Domain xxPrepare a Second Member Server and Join It to the Domain xxiPrepare a Third Member Server and Join It to the Domain xxiPrepare a Fourth Member Server and Join It to the Domain xxiiPrepare a Computer Running the Server Core Installation Option and Join It to the Domain xxiiUsing the Companion CD xxiiiHow to Install the Practice Tests xxivHow to Use the Practice Tests xxivHow to Uninstall the Practice Tests xxvAcknowledgments xxvErrata & Book Support xxvWe Want to Hear from You xxvStay in Touch xxvPreparing for the Exam xxviCHAPTER 1Planning and Installing SQL Server 2012 1Before You Begin 1Lesson 1: Planning Your Installation 2Evaluating Installation Requirements 2Designing the Installation 7Planning Scale Up versus Scale Out Basics 8Shrinking and Growing Databases 9Designing the Storage for New Databases 13Remembering Capacity Constraints 15Identifying a Standby Database for Reporting 15Identifying Windows-Level Security and Service-Level Security 15Performing a Core Mode Installation 17Benchmarking a Server 19Lesson Summary 23Lesson Review 24Lesson 2: Installing SQL Server and Related Services 26Configuring an Operating System Disk 26Installing the SQL Server Database Engine 27Installing SQL Server 2012 from the Command Prompt 33Installing SQL Server Integration Services 34Enabling and Disabling Features 36Installing SQL Server 2012 by Using a Configuration File 39Testing Connectivity 40Lesson Summary 52Lesson Review 53Case Scenarios 54Case Scenario 1: Planning Deployment of SQL Server 2012 54Case Scenario 2: SQL Server Deployment 54Suggested Practices 55Configure Additional Firewall Rules and Generate a Features Discovery Report 55Adding and Removing Features and Adding Databases to SQL Server 2012 on a Computer Running a Server Core Operating System 55Answers 56Lesson 1 56Lesson 2 57Case Scenario 1 58Case Scenario 2 59CHAPTER 2Configuring and Managing SQL Server Instances 61Before You Begin 61Lesson 1: Configuring SQL Server Instances 62Instance-Level Settings 62Database Configuration and Standardization 68Distributed Transaction Coordinator 71Configuring Database Mail 72Lesson Summary 78Lesson Review 78Lesson 2: Managing SQL Server Instances 80Installing Additional Instances 80Deploying Software Updates and Patch Management 84Configuring Resource Governor 86Using WSRM with Multiple Database Engine Instances 91Cycle SQL Server Error Logs 93Lesson Summary 96Lesson Review 96Case Scenarios 98Case Scenario 1: Instance Configuration 98Case Scenario 2: Additional Instances and Error Log Cycling 98Suggested Practices 99Configure Instances 99Install and Manage Multiple Instances 99Answers 100Lesson 1 100Lesson 2 101Case Scenario 1 103Case Scenario 2 104CHAPTER 3Configuring SQL Server 2012 Components 105Before You Begin 105
Lesson 1: Configuring Additional SQL Server Components 106Deploying and Configuring Analysis Services 106Deploying and Configuring Reporting Services 108Deploying and Configuring SharePoint Integration 112Configuring SQL Server Integration Services Security 114Managing Full-Text Indexing 116Configuring FILESTREAM 118Configuring FileTables 120Lesson Summary 123Lesson Review 124Lesson 2: Managing and Configuring Databases 125Designing and Managing Filegroups 125Configuring and Standardizing Databases 128Understanding Contained Databases 128Using Data Compression 131Encrypting Databases with Transparent Data Encryption 135Partitioning Indexes and Tables 137Managing Log Files 140Using Database Console Commands 141Lesson Summary 146Lesson Review 146Case Scenarios 147Case Scenario 1: Configuring FILESTREAM and FileTable 147Case Scenario 2: Deploying Transparent Data Encryption 148Suggested Practices 148FILESTREAM and FileTable 148Transparent Data Encryption and Table Partitioning 148Answers 149Lesson 1 149Lesson 2 150Case Scenario 1 151Case Scenario 2 151CHAPTER 4Migrating, Importing, and Exporting 153Before You Begin 153Lesson 1: Migrating to SQL Server 2012 154Upgrading an Instance to SQL Server 2012 154Migrating a Database to a SQL Server 2012 Instance 161Copying Databases to Other Servers 164Migrating SQL Logins 170Lesson Summary 173Lesson Review 173Lesson 2: Exporting and Importing Data 175Copying and Exporting Data 175Using the SQL Server Import and Export Wizard 176Using BCP to Import and Export Data 178Importing Data by Using BULK INSERT 179Importing Data by Using OPENROWSET(BULK) 180Using Format Files 180Preparing Data for Bulk Operations 181SELECT INTO 182Lesson Summary 184Lesson Review 184Case Scenarios 185Case Scenario 1: Consolidation at Contoso 186Case Scenario 2: Tailspin Toys Bulk Data 186Suggested Practices 187Implement a Migration Strategy 187Import and Export Data 187Answers 188Lesson 1 188Lesson 2 189Case Scenario 1 190Case Scenario 2 191CHAPTER 5SQL Server Logins, Roles, and Users 193Before You Begin 193Lesson 1: Managing Logins and Server Roles 194SQL Logins 194Server Roles 201User-Defined Server Roles 203Credentials 204Lesson Summary 206Lesson Review 207Lesson 2: Managing Users and Database Roles 209Database Users 209Database Roles 211Contained Users 216Least Privilege 218Application Roles 218Lesson Summary 221Lesson Review 221Case Scenarios 222
Case Scenario 1: Instance-Level Permissions for Contoso’s Accountants 222Case Scenario 2: Contained Databases at Fabrikam 223Suggested Practices 223Manage Logins and Server Roles 223Manage Users and Database Roles 224Answers 225Lesson 1 225Lesson 2 226Case Scenario 1 228Case Scenario 2 228CHAPTER 6Securing SQL Server 2012 229Before You Begin 229Lesson 1: Managing Database Permissions 230Understanding Securables 230Assigning Permissions on Objects 232Managing Permissions by Using Database Roles 233Protecting Objects from Modification 236Using Schemas 236Determining Effective Permissions 238Lesson Summary 239Lesson Review 239Lesson 2: Troubleshooting SQL Server Security 241Troubleshooting Authentication 241Troubleshooting Certificates and Keys 244Troubleshooting Endpoints 245Using Security Catalog Views 246Lesson Summary 247Lesson Review 248Lesson 3: Auditing SQL Server Instances 250Using SQL Server Audit 250Configuring Login Auditing 262Using c2 Audit Mode 263Common Criteria Compliance 264Policy-Based Management 264Lesson Summary 270Lesson Review 270Case Scenarios 271Case Scenario 1: Configuring Database Permissions 272Case Scenario 2: Troubleshooting Security 272Case Scenario 3: Auditing at Fabrikam 272Suggested Practices 273Manage Database Permissions 273Troubleshoot Security 273Audit SQL Server Instances 273Answers 274Lesson 1 274Lesson 2 275Lesson 3 276Case Scenario 1 277Case Scenario 2 277Case Scenario 3 277CHAPTER 7 Mirroring and Replication 279Before You Begin 279Lesson 1: Mirroring Databases 280Database Mirroring 280Mirroring Prerequisites 281Configuring Mirroring with Windows Authentication 285Configuring Mirroring with Certificate Authentication 288Changing Operating Modes 290Role Switching and Failover 291Monitoring Mirrored Databases 292Upgrading Mirrored Databases 294Lesson Summary 298Lesson Review 298Lesson 2: Database Replication 300Replication Architecture 300Replication Types 302Snapshot Replication 303Transactional Replication 307Peer-to-Peer Transactional Replication 309Merge Replication 311Replication Monitor 315Controlling Replication of Constraints, Columns, and Triggers 317Heterogeneous Data 318Lesson Summary 320
Lesson Review 321Case Scenarios 322Case Scenario 1: Database Mirroring at Coho Vineyard 322Case Scenario 2: Database Replication at Tailspin Toys 322Suggested Practices 323Implement Database Mirroring 323Implement Replication 323Answers 324Lesson 1 324Lesson 2 325Case Scenario 1 326Case Scenario 2 326CHAPTER 8Clustering and AlwaysOn 327Before You Begin 327Lesson 1: Clustering SQL Server 2012 328Fulfilling Edition Prerequisites 328Creating a Windows Server 2008 R2 Failover Cluster 332Installing a SQL Server Failover Cluster 334Multi-Subnet Failover Clustering 338Performing Manual Failover 339Troubleshooting Failover Clusters 340Lesson Summary 344Lesson Review 344Lesson 2: AlwaysOn Availability Groups 346What Are AlwaysOn Availability Groups? 346Meeting Availability Group Prerequisites 347Configuring Availability Modes 347Selecting Failover Modes 349Configuring Readable Secondary Replicas 352Deploying AlwaysOn Availability Groups 353Using Availability Groups on Failover Cluster Instances 360Lesson Summary 364Lesson Review 364Case Scenarios 365Case Scenario 1: Failover Cluster Instances at Contoso 365Case Scenario 2: AlwaysOn Availability Groups at Fabrikam 366Suggested Practices 366Implement a SQL Server Clustered Instance 366Implement AlwaysOn 366Answers 367Lesson 1 367Lesson 2 368Case Scenario 1 369Case Scenario 2 369CHAPTER 9Troubleshooting SQL Server 2012 371Before You Begin 371Lesson 1: Working with Performance Monitor 372Getting Started with Performance Monitor 372Capturing Performance Monitor Data 374Creating Data Collector Sets 376Lesson Summary 377Lesson Review 378Lesson 2: Working with SQL Server Profiler 379Capturing Activity with SQL Server Profiler 379Understanding SQL Trace 384Reviewing Trace Output 385Capturing Activity with Extended Events Profiler 385Lesson Summary 387Lesson Review 387Lesson 3: Monitoring SQL Server 389Monitoring Activity 389Working with Activity Monitor 392Lesson Summary 393Lesson Review 393Lesson 4: Using the Data Collector Tool 395Capturing and Managing Performance Data 395Analyzing Collected Performance Data 399Lesson Summary 401
Lesson Review 402Lesson 5: Identifying Bottlenecks 403Monitoring Disk Usage 403Monitoring Memory Usage 405Monitoring CPU Usage 406Lesson Summary 407Lesson Review 408Case Scenarios 408Case Scenario 1: Identifying Poor Query Performance 408Case Scenario 2: Deploying Auditing 409Suggested Practices 409Create a Trace by Using SQL Server Profiler 409Capture a Performance Baseline by Using Performance Monitor 409Answers 410Lesson 1 410Lesson 2 411Lesson 3 411Lesson 4 412Lesson 5 413Case Scenario 1 414Case Scenario 2 414CHAPTER 10Indexes and Concurrency 417Before You Begin 417Lesson 1: Implementing and Maintaining Indexes 418Understanding the Anatomy of a Balanced Tree (B-Tree) 418Understanding Index Types and Structures 420Designing Indexes for Efficient Retrieval 423Understanding Statistics 428Creating and Modifying Indexes 430Tracking Missing Indexes 437Reviewing Unused Indexes 437Lesson Summary 440Lesson Review 440Lesson 2: Identifying and Resolving Concurrency Problems 442Defining Transactions and Transaction Scope 442Understanding SQL Server Lock Management 442Using AlwaysOn Replicas to Improve Concurrency 449Detecting and Correcting Deadlocks 450Using Activity Monitor 452Diagnosing Bottlenecks 453Using Reports for Performance Analysis 454Lesson Summary 457Lesson Review 458Case Scenarios 458Case Scenario 1: Fabrikam Year-Query Performance 459Case Scenario 2: Analyzing Concurrency at Tailspin Toys 459Suggested Practices 460Implement and Maintain Indexes and Statistics 460Identify and Resolve Concurrency Problems 460Answers 461Lesson 1 461Lesson 2 462Case Scenario 1 463Case Scenario 2 463CHAPTER 11SQL Server Agent, Backup, and Restore 465Before You Begin 465Lesson 1: Managing SQL Server Agent 466Executing Jobs by Using SQL Server Agent 466Managing Alerts 471Managing Jobs 474Monitoring Multi-Server Environments 481Lesson Summary 484Lesson Review 485
Lesson 2: Configuring and Maintaining a Backup Strategy 487Understanding Backup Types 487Backing Up System Databases 491Backing Up Replicated Databases 492Backing Up Mirrored Databases 493Backing Up AlwaysOn Replicas 493Using Database Checkpoints 494Using Backup Devices 495Backing Up Media Sets 497Performing Backups 497Viewing Backup History 501Lesson Summary 502Lesson Review 503Lesson 3: Restoring SQL Server Databases 504Restoring Databases 504Performing File Restores 508Performing Page Restores 509Restoring a Database Protected with Transparent Data Encryption 511Restoring System Databases 511Restoring Replicated Databases 512Checking Database Status 512Lesson Summary 514Lesson Review 515Case Scenarios 516Case Scenario 1: SQL Server Agent at Contoso 516Case Scenario 2: Fabrikam Backup Strategy 516Case Scenario 3: Recovery at Adatum 517Suggested Practices 517Manage SQL Server Agent 517Configure and Maintain a Backup Strategy 517Restore Databases 518Answers 519Lesson 1 519Lesson 2 520Lesson 3 521Case Scenario 1 522Case Scenario 2 522Case Scenario 3 522CHAPTER 12 Code Case Studies 523Case Study 1 523Questions 524Case Study 2 528Questions 529Case Study 3 533Questions 534Case Study 4 539Questions 540Answers 545Case Study 1 545Case Study 2 550Case Study 3 554Case Study 4 560About the Authors 595Contributor 596
PUBLISHED BYMicrosoft PressA Division of Microsoft CorporationOne Microsoft WayRedmond, Washington 98052-6399
Copyright © 2012 by Orin Thomas (Content); Orin Thomas (Sample Code); Peter Ward (Sample Code); Peter Ward (Content)
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher.
Library of Congress Control Number: 2012938612ISBN: 978-0-7356-6607-8
Printed and bound in the United States of America.
First Printing
Microsoft Press books are available through booksellers and distributors worldwide. If you need support related to this book, email Microsoft Press Book Support at [email protected]. Please tell us what you think of this book at http://www.microsoft.com/learning/booksurvey.
Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty /Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respective owners.
The example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, email address, logo, person, place, or event is intended or should be inferred.
This book expresses the authors’ views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book.
Acquisitions Editor: Anne HamiltonDevelopmental Editor: Karen Szall Project Editor: Karen Szall Editorial Production: nSight, Inc. Technical Reviewer: boB Taylor; Technical Review services provided by Content Master, a member of CM Group, Ltd. Copyeditor: Kerin Forsyth Indexer: Lucie Haskins Cover: Twist Creative • Seattle
Contents
Introduction xvii
CHAPTER 1 Planning and Installing SQL Server 2012 1
CHAPTER 2 Configuring and Managing SQL Server Instances 61
CHAPTER 3 Configuring SQL Server 2012 Components 105
CHAPTER 4 Migrating, Importing, and Exporting 153
CHAPTER 5 SQL Server Logins, Roles, and Users 193
CHAPTER 6 Securing SQL Server 2012 229
CHAPTER 7 Mirroring and Replication 279
CHAPTER 8 Clustering and AlwaysOn 327
CHAPTER 9 Troubleshooting SQL Server 2012 371
CHAPTER 10 Indexes and Concurrency 417
CHAPTER 11 SQL Server Agent, Backup, and Restore 465
CHAPTER 12 Code Case Studies 523
Index 567
vii
Contents
Introduction xviiSystem Requirements xvii
Practice Setup Instructions xix
Using the Companion CD xxiii
Acknowledgments xxv
Errata & Book Support xxv
We Want to Hear from You xxv
Stay in Touch xxv
Preparing for the Exam xxvii
Chapter 1 Planning and Installing SQL Server 2012 1Lesson 1: Planning Your Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Evaluating Installation Requirements 2
Designing the Installation 7
Planning Scale Up versus Scale Out Basics 8
Shrinking and Growing Databases 9
Designing the Storage for New Databases 13
Remembering Capacity Constraints 15
Identifying a Standby Database for Reporting 15
Identifying Windows-Level Security and Service-Level Security 15
Performing a Core Mode Installation 17
Benchmarking a Server 19
Lesson Summary 23
Lesson Review 24
Lesson 2: Installing SQL Server and Related Services . . . . . . . . . . . . . . . . . 26
What do you think of this book? We want to hear from you! Microsoft is interested in hearing your feedback so we can continually improve our books and learning resources for you. To participate in a brief online survey, please visit:
microsoft.com/learning/booksurvey
viii Contents
Configuring an Operating System Disk 26
Installing the SQL Server Database Engine 27
Installing SQL Server 2012 from the Command Prompt 33
Installing SQL Server Integration Services 34
Enabling and Disabling Features 36
Installing SQL Server 2012 by Using a Configuration File 39
Testing Connectivity 40
Lesson Summary 52
Lesson Review 53
Case Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Suggested Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Chapter 2 Configuring and Managing SQL Server Instances 61Lesson 1: Configuring SQL Server Instances . . . . . . . . . . . . . . . . . . . . . . . . . 62
Instance-Level Settings 62
Database Configuration and Standardization 68
Distributed Transaction Coordinator 71
Configuring Database Mail 72
Lesson Summary 78
Lesson Review 78
Lesson 2: Managing SQL Server Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Installing Additional Instances 80
Deploying Software Updates and Patch Management 84
Configuring Resource Governor 86
Using WSRM with Multiple Database Engine Instances 91
Cycle SQL Server Error Logs 93
Lesson Summary 96
Lesson Review 96
Case Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Suggested Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
ixContents
Chapter 3 Configuring SQL Server 2012 Components 105Lesson 1: Configuring Additional SQL Server Components . . . . . . . . . . . 106
Deploying and Configuring Analysis Services 106
Deploying and Configuring Reporting Services 108
Deploying and Configuring SharePoint Integration 112
Configuring SQL Server Integration Services Security 114
Managing Full-Text Indexing 116
Configuring FILESTREAM 118
Configuring FileTables 120
Lesson Summary 123
Lesson Review 124
Lesson 2: Managing and Configuring Databases . . . . . . . . . . . . . . . . . . . . 125
Designing and Managing Filegroups 125
Configuring and Standardizing Databases 128
Understanding Contained Databases 128
Using Data Compression 131
Encrypting Databases with Transparent Data Encryption 135
Partitioning Indexes and Tables 137
Managing Log Files 140
Using Database Console Commands 141
Lesson Summary 146
Lesson Review 146
Case Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Suggested Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Chapter 4 Migrating, Importing, and Exporting 153Lesson 1: Migrating to SQL Server 2012 . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Upgrading an Instance to SQL Server 2012 154
Migrating a Database to a SQL Server 2012 Instance 161
Copying Databases to Other Servers 164
Migrating SQL Logins 170
x Contents
Lesson Summary 173
Lesson Review 173
Lesson 2: Exporting and Importing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Copying and Exporting Data 175
Using the SQL Server Import and Export Wizard 176
Using BCP to Import and Export Data 178
Importing Data by Using BULK INSERT 179
Importing Data by Using OPENROWSET(BULK) 180
Using Format Files 180
Preparing Data for Bulk Operations 181
SELECT INTO 182
Lesson Summary 184
Lesson Review 184
Case Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Suggested Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Chapter 5 SQL Server Logins, Roles, and Users 193Lesson 1: Managing Logins and Server Roles . . . . . . . . . . . . . . . . . . . . . . . 194
SQL Logins 194
Server Roles 201
User-Defined Server Roles 203
Credentials 204
Lesson Summary 206
Lesson Review 207
Lesson 2: Managing Users and Database Roles . . . . . . . . . . . . . . . . . . . . . 209
Database Users 209
Database Roles 211
Contained Users 216
Least Privilege 218
Application Roles 218
Lesson Summary 221
Lesson Review 221