SQL Server 2008 And 2008 R2 - Info.microsoft

Transcription

SQL Server 2008 and 2008 R2end of support is comingSQL Server 2008 and SQL Server 2008 R2 will no longer be supported by Microsoftstarting in July 2019. Avoid challenges and vulnerabilities caused by end of support.Why should you upgrade?Mitigate risks with platform security and complianceThere will be no access to critical security updates, opening the potential for business interruptions andloss of data.Upgrade to better cost efficiencyMaintaining legacy servers, firewalls, intrusion systems, and other tools can get expensive quickly.Modernize to innovateGrow your environments with data, analytics and the cloud.More than an upgradeWith SQL Server 2017 you don’t just get an update—you get inmemory performance across workloads, mission-critical highavailability, and built-in security features to help protect your dataat rest and in motion.SQL#1 OLTP performance 1#1 DW performance on 1TB 2 , 10TB 3 , and 30TB 4#1 OLTP price/performance 5Learn more about SQL Server 2017#1 DW price/performance on 1TB 2 , 10TB 3 , and 30TB 4End of support options for SQL Server 2008 and 2008 R2Take advantage of the AzureHybrid BenefitExtended Security Updates foron-premises environmentsFree Extended Security Updatesin AzureSave when you migrate your SQL Server 2008or 2008 R2 workloads to Azure SQL Databasewith the Azure Hybrid Benefit for SQL Server.Learn more.Customers with Software Assurance or subscriptionlicenses may purchase Extended Security Updatesfor three years of security updates for SQL Server2008 and 2008 R2. Learn more.Lift and shift your SQL Server 2008 workloads toAzure with no application code changes. Thisgives you more time to plan for end of support.Learn more.Learn more about SQL Server 2008 and 2008 R2 end of support 2018 Microsoft Corporation. All rights reserved.All TPC Claims as of 1/19/2018. 1http://www.tpc.org/4081; 2http://www.tpc.org/3331; 3http://www.tpc.org/3326; 4http://www.tpc.org/3321; 5http://www.tpc.org/4080

Keep learning from the inside out—and save!Save 50% when you purchase the complete eBook edition ofSQL Server 2017 Administration Inside Out by William Assaf, RandolphWest, Sven Aelterman, and Mindy Curnutt.Visit microsoftpressstore.com/SQLAdmin to select title and use codeSQLADMIN during checkout to apply discount. The eBook is deliveredin EPUB, PDF, and MOBI to read on your preferred device.Sign up to receive more special offers from Microsoft Press atmicrosoftpressstore.com/newslettersDiscount code valid on eBook purchase from microsoftpressstore.com and cannot be combined with another offer.Microsoft Press products are published, marketed, and distributed by Pearson.

SQL Server 2017Administration Inside OutSecond EditionWilliam AssafRandolph WestSven AeltermanMindy Curnutt

Published with the authorization of Microsoft Corporation by:Pearson Education, Inc.Copyright 2018 by Pearson Education Inc.All rights reserved. Printed in the United States of America. This publication is protected by copyright, andpermission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system,or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. Forinformation regarding permissions, request forms, and the appropriate contacts within the Pearson EducationGlobal Rights & Permissions Department, please visit www.pearsoned.com/permissions/. No patent liability isassumed with respect to the use of the information contained herein. Although every precaution has been takenin the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor isany liability assumed for damages resulting from the use of the information contained herein.ISBN-13: 978-1-5093-0521-6ISBN-10: 1-5093-0521-1Library of Congress Control Number: 2017961300Printed and bound in the United States of America.1 18TrademarksMicrosoft and the trademarks listed at https://www.microsoft.com on the “Trademarks” webpage are trademarksof the Microsoft group of companies. All other marks are property of their respective owners.Warning and DisclaimerEvery effort has been made to make this book as complete and as accurate as possible, but no warranty or fitnessis implied. The information provided is on an “as is” basis. The authors, the publisher, and Microsoft Corporationshall have neither liability nor responsibility to any person or entity with respect to any loss or damages arisingfrom the information contained in this book or programs accompanying it.Special SalesFor information about buying this title in bulk quantities, or for special sales opportunities (which may includeelectronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, orbranding interests), please contact our corporate sales department at corpsales@pearsoned.com or (800) 382-3419.For government sales inquiries, please contact governmentsales@pearsoned.com.For questions about sales outside the U.S., please contact intlcs@pearson.com.Editor-in-Chief: Greg WiegandAcquisitions Editor: Trina MacDonaldDevelopment Editor: Mark RenfrowTechnical Editor: Louis DavidsonManaging Editor: Sandra SchroederSenior Project Editor: Tracey CroomEditorial Production: Octal Publishing, Inc.Copy Editor: Octal Publishing, Inc.Indexer: Octal Publishing, Inc.Proofreader: Octal Publishing, Inc.Cover Designer: Twist Creative, Seattle

To David IIIfor inspiring and enabling STEM careers for many, including my own.—William AssafTo Marinus and Trixiefor putting up with the lies of “almost done,” and sharing my lap with a MacBook.—Randolph WestTo Ebony, Edward, and Sofiain recognition of their sacrifices, support, and endless love.—Sven AeltermanTo ChrisFor believing in me more than I even believed in myself.—Mindy Curnutt

This page intentionally left blank

Contents at a glanceChapter 1Getting started with SQL Server tools. . . . . . . . . . . 1Chapter 8Understanding and designing tables . . . . . . . . 333Chapter 2Introducing database server components . . . . 45Chapter 9Performance tuning SQL Server. . . . . . . . . . . . . 383Chapter 3Designing and implementing a databaseinfrastructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79infrastructureChapter 10Understanding and designing indexes. . . . . . . 429Chapter 4Provisioning databases . . . . . . . . . . . . . . . . . . . . . 127Chapter 11Developing, deploying, and managing datarecovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459Chapter 5Provisioning Azure SQL Database . . . . . . . . . . . 197Chapter 12Implementing high availability and disasterrecovery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493Chapter 6Administering security and permissions . . . . . 241Chapter 13Managing and monitoring SQL Server. . . . . . . 557Chapter 7Securing the server and its data. . . . . . . . . . . . . 291Chapter 14Automating SQL Server administration . . . . . . 607v

This page intentionally left blank

Table of contentsForeword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviiIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xixWho this book is for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xixAssumptions about you . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xixHow this book is organized . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxAbout the companion content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiiAcknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiiSupport and feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxivErrata & support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxivStay in touch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxivChapter 1Getting started with SQL Server tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1SQL Server setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Installing SQL Server by using the Installation Center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Planning before an upgrade or installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Installing or upgrading SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Tools and services installed with the SQL Server Database Engine . . . . . . . . . . . . . . . . . . . . . . . . 7Machine Learning Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Data Quality Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Command-line interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9SQL Server Configuration Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Performance and reliability monitoring tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Database Engine Tuning Advisor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Extended events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Management data warehouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15SQL Server Reporting Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Report Services Configuration Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20vii

viiiTable of contentsSQL Server Management Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Releases and versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Installing SQL Server Management Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Upgrading SQL Server Management Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22Features of SQL Server Management Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Additional tools in SQL Server Management Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Error logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32Activity Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33SQL Server Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37SQL Server Data Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41SQL Server Integration Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41A note on deprecation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Chapter 2Introducing database server components . . . . . . . . . . . . . . . . . . . . . . . . . . 45Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Understanding the working set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46Caching data in the buffer pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46Caching plans in the procedure cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47Lock pages in memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47Editions and memory limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48Central Processing Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Simultaneous multithreading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Non-Uniform Memory Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50Disable power saving everywhere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Storing your data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Types of storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52Configuring the storage layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Connecting to SQL Server over the network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Protocols and ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Added complexity with Virtual Local-Area Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58High availability concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59Why redundancy matters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Disaster recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61The versatility of Log Shipping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63Always On availability groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64Read-scale availability groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66Distributed availability groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67Basic availability groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67Improve redundancy and performance with NIC teaming . . . . . . . . . . . . . . . . . . . . . . . 67Securing SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68Integrated authentication and Active Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68Azure Active Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71Abstracting hardware with virtualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Resource provisioning for VMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74When processors are no longer processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75The network is virtual, too . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

Table of contentsChapter 3ixDesigning and implementing a database infrastructure . . . . . . . . . . . . . 79Physical database architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79Data files and filegroups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80Recording changes in the transaction log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85Table partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Data compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93Managing the temporary database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96Configuration settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98Managing system usage by using Resource Governor . . . . . . . . . . . . . . . . . . . . . . . . . . . 98Configuring the page file (Windows) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99Taking advantage of logical processors by using parallelism . . . . . . . . . . . . . . . . . . . . 100SQL Server memory settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102Carving up CPU cores using an affinity mask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105File system configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107Azure and the Data Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110Infrastructure as a service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110Platform as a service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116Hybrid cloud with Azure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121Chapter 4Provisioning databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127What to do before installing SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127Deciding on volume usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127Important SQL Server volume settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130SQL Server editions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131Installing a new instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134Planning for multiple SQL Server instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134Installing a SQL Server instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134Installing options and features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137Installing other core features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142“Smart Setup” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146Setting up logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147Automating SQL Server Setup by using configuration files . . . . . . . . . . . . . . . . . . . . . . . 147Post-installation server configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151Post-installation checklist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151Installing and configuring features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164SSISDB initial configuration and setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164SQL Server Reporting Services initial configuration and setup . . . . . . . . . . . . . . . . . . . 165SQL Server Analysis Services initial configuration and setup . . . . . . . . . . . . . . . . . . . . 168Adding databases to a SQL Server instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169Considerations for migrating existing databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169Moving existing databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175Creating a database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177Database properties and options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181Moving and removing databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189Moving user and system databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189Database actions: offline versus detach versus drop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191Single-user mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

xTable of contentsChapter 5Provisioning Azure SQL Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197Azure and database-as-a-service concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198Database-as-a-service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198Managing Azure: The Azure portal and PowerShell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199Azure governance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200Logical SQL Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201Cloud-first . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Database Transaction Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Resource scalability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203Provisioning a logical SQL server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204Creating a server using the Azure portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205Creating a server by using PowerShell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206Establishing a connection to your server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207Deleting a server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209Provisioning a database in Azure SQL Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209Creating a database using the Azure portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210Creating a database by using PowerShell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211Creating a database by using Azure CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212Creating a database by using T-SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213Selecting a pricing tier and service objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213Scaling up or down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214Provisioning an elastic pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214Limitations of Azure SQL Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215Database limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215Other SQL Server services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216Overcoming limitations with managed instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218Security in Azure SQL Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218Security features shared with SQL Server 2017 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219Server and database-level firewall . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219Access control using Azure AD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222Role-Based Access Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Auditing and threat detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Preparing Azure SQL Database for disaster recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229Understanding default disaster recovery features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229Manually backing up a database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230Configuring geo-replication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232Setting up failover groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235Using Azure Backup for long-term backup retention . . . . . . . . . . . . . . . . . . . . . . . . . . . 237Moving to Azure SQL Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239Chapter 6Administering security and permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . 241Logins and users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241Different types of authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242Solving orphaned SIDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246Preventing orphaned SIDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Factors in securing logins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Login security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254Contained databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256

Table of contentsxiPermissions in SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257Understanding Permissions for Data Definition Language and . . . . . . . . . . . . . . . . . 257Data Manipulatio

End of support options for SQL Server 2008 and 2008 R2 Take advantage of the Azure Hybrid Benefit Save when you migrate your SQL Server 2008 or 2008 R2 workloads to Azure SQL Database with the Azure Hybrid Benefit for SQL Server. Learn more. Extended Security Updates for on-premises envir