Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

SQL Server 2022 Administration Inside

Out 1st Edition Randolph West


Visit to download the full and correct content document:
https://ebookmass.com/product/sql-server-2022-administration-inside-out-1st-edition-r
andolph-west/
SQL Server 2022
Administration Inside Out

Randolph West
William Assaf
Elizabeth Noble
Meagan Longoria
Joey D’Antoni
Louis Davidson

With contributions from:


William Carter
Josh Smith
Melody Zacharias
SQL Server 2022 Administration Inside Out Published with the
authorization of Microsoft Corporation by: Pearson Education,
Inc.

Copyright © 2023 by Pearson Education.

All rights reserved. This publication is protected by copyright, and


permission 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. For information regarding
permissions, request forms, and the appropriate contacts within the
Pearson Education Global Rights & Permissions Department, please
visit www.pearson.com/permissions.

No patent liability is assumed with respect to the use of the


information contained herein. Although every precaution has been
taken in the preparation of this book, the publisher and author
assume no responsibility for errors or omissions. Nor is any liability
assumed for damages resulting from the use of the information
contained herein.

ISBN-13: 978-0-13-789988-3
ISBN-10: 0-13-789988-2

Library of Congress Control Number: 2023930547

ScoutAutomatedPrintCode

Trademarks
Microsoft and the trademarks listed at http://www.microsoft.com on
the “Trademarks” webpage are trademarks of the Microsoft group of
companies. All other marks are property of their respective owners.
Warning and Disclaimer
Every effort has been made to make this book as complete and as
accurate as possible, but no warranty or fitness is implied. The
information provided is on an "as is" basis. The author, the publisher,
and Microsoft Corporation shall have neither liability nor
responsibility to any person or entity with respect to any loss or
damages arising from the information contained in this book or from
the use of the programs accompanying it.

Special Sales
For information about buying this title in bulk quantities, or for special
sales opportunities (which may include electronic versions; custom
cover designs; and content particular to your business, training
goals, marketing focus, or branding 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: Brett Bartow


Executive Editor: Loretta Yates
Associate Editor: Charvi Arora
Development Editor: Kate Shoup
Technical Reviewers: William Carter, Louis Davidson, Meagan Longoria,
Elizabeth Noble, Josh Smith
Managing Editor: Sandra Schroeder
Senior Project Editor: Tracey Croom
Copy Editor: Rebecca Rider
Indexer: Rachel Kuhn
Proofreaders: Audrey Doyle, James Fraleigh
Editorial Assistant: Cindy Teeters
Cover Designer: Twist Creative, Seattle
Compositor: Jeff Lytle, Happenstance Type-O-Rama
Graphics: Jeff Wilson, Happenstance Type-O-Rama
Pearson’s Commitment to Diversity,
Equity, and Inclusion
Pearson is dedicated to creating bias-free content that reflects the
diversity of all learners. We embrace the many dimensions of
diversity, including but not limited to race, ethnicity, gender,
socioeconomic status, ability, age, sexual orientation, and religious
or political beliefs.
Education is a powerful force for equity and change in our world. It
has the potential to deliver opportunities that improve lives and
enable economic mobility. As we work with authors to create content
for every product and service, we acknowledge our responsibility to
demonstrate inclusivity and incorporate diverse scholarship so that
everyone can achieve their potential through learning. As the world’s
leading learning company, we have a duty to help drive change and
live up to our purpose to help more people create a better life for
themselves and to create a better world.
Our ambition is to purposefully contribute to a world where:

Everyone has an equitable and lifelong opportunity to succeed


through learning.
Our educational products and services are inclusive and
represent the rich diversity of learners.
Our educational content accurately reflects the histories and
experiences of the learners we serve.
Our educational content prompts deeper discussions with
learners and motivates them to expand their own learning (and
worldview).
While we work hard to present unbiased content, we want to hear
from you about any concerns or needs with this Pearson product so
that we can investigate and address them.

Please contact us with concerns about any potential bias at


https://www.pearson.com/report-bias.html.
Dedications
To Marinus (as always), to the friends we’ve lost along the way, and
to the friends we make by saying “yes” to new opportunities.
—Randolph West

The previous book in this series was published in March 2020, at the
advent of a historic disruption: social, political, economic, and
educational. I dedicate this book to all those who have been made
unsafe and further marginalized by the COVID-19 pandemic.
—William Assaf

To Mind, Danny, Eve, Mom, and Dad, for your encouragement and
support.
—Elizabeth Noble

I dedicate this book to my dad, who passed away in 2022. He was


always supportive of my educational and professional goals.
—Meagan Longoria

I would like to thank my other authors and my family for helping this
work go so smoothly.
—Joey D’Antoni

To all my friends at CBN who provided me with training, inspiration,


practice, and until recently, servers to test code on for so many
years.
—Louis Davidson
To all those who need someone to believe in them. Know that there
are two, Me and You, because as Henry Ford said, “Whether you
think you can or you can’t, you’re right!”
—Melody Zacharias

In memory of Ruby Jean Carter. You were the embodiment of love,


patience, and strength.
—William Carter

For data professionals everywhere always looking to learn and grow.


—Josh Smith
Contents at a glance

Foreword
Introduction

Part I: Introduction
Chapter 1 Get started with SQL Server tools
Chapter 2 Introduction to database server components
Chapter 3 Design and implement an on-premises
database infrastructure

Part II: Deployment


Chapter 4 Install and configure SQL Server instances
and features
Chapter 5 Install and configure SQL Server on Linux
Chapter 6 Provision and configure SQL Server
databases
Chapter 7 Understand table features

Part III: SQL Server management


Chapter 8 Maintain and monitor SQL Server
Chapter 9 Automate SQL Server administration
Chapter 10 Develop, deploy, and manage data recovery
Chapter 11 Implement high availability and disaster
recovery

Part IV: Security


Chapter 12 Administer instance and database security
and permissions
Chapter 13 Protect data through classification,
encryption, and auditing

Part V: Performance
Chapter 14 Performance tune SQL Server
Chapter 15 Understand and design indexes

Part VI: Cloud


Chapter 16 Design and implement hybrid and Azure
database infrastructure
Chapter 17 Provision Azure SQL Database
Chapter 18 Provision Azure SQL Managed Instance
Chapter 19 Migrate to SQL Server solutions in Azure
Index
Table of Contents

About the Authors


Acknowledgments

Foreword

Introduction
Who this book is for
How this book is organized
Conventions
Text conventions
Book features
Errata, updates, and book support

Part I: Introduction

Chapter 1 Get started with SQL Server tools


SQL Server setup
Install SQL Server with the Installation
Center
Plan before an upgrade or installation
Install or upgrade SQL Server
Tools and services installed with the Database
Engine
Machine Learning Services
Data Quality Services
Command line interface
SQL Server Configuration Manager
Performance and reliability monitoring tools
Database Engine Tuning Advisor
Extended Events
Management Data Warehouse
SQL Server Reporting Services (SSRS)
Installation
Report Server Configuration Manager
SQL Server Management Studio (SSMS)
Releases and versions
Install SQL Server Management Studio
Upgrade SQL Server Management Studio
Features of SQL Server Management
Studio
Additional tools in SQL Server Management
Studio
Error logs
Activity Monitor
SQL Server Agent
Azure Data Studio
User interface
Highlighted features in Azure Data Studio
Notebooks in Azure Data Studio
SQL Server Data Tools
SQL Server Integration Services
SQL Server on Azure Arc–enabled servers
Microsoft Purview
Discontinued and deprecated features

Chapter 2 Introduction to database server


components
Memory
Understand the working set
Cache data in the buffer pool
Cached plans in the procedure cache
Lock pages in memory
Editions and memory limits
Central processing unit
Simultaneous multithreading
Non-uniform memory access
Disable power saving everywhere
Data storage
Types of storage
Configure the storage layer
Connect to SQL Server over the network
Protocols and ports
Added complexity with Virtual Local Area
Networks
High-availability concepts
Why redundancy matters
Disaster recovery
Clustering
The versatility of log shipping
Always On availability groups
Secure SQL Server
Integrated Authentication and Active
Directory
Azure Active Directory
Kerberos for Azure SQL Managed Instance
Understand virtualization and containers
Going virtual
Provision resources for virtual consumers
When processors are no longer processors
The network is virtual, too

Chapter 3 Design and implement an on-premises


database infrastructure
Introduction to SQL Server database architecture
Data files and filegroups
Group data pages with extents
Contents and types of data pages
Verify data pages by using a checksum
Record changes in the transaction log
Flush data to the storage subsystem with
checkpoints
Inside the transaction log file
The Minimum Recovery LSN
Types of database checkpoints
Restart with recovery
MinLSN and the active log
A faster recovery with accelerated database
recovery
Partition tables
Compress data
Table and index compression
Backup compression
Manage the temporary database
Storage options for tempdb
Recommended number of files
Configuration settings
Manage system usage with Resource
Governor
Configure the operating system page file
Take advantage of logical processors with
parallelism
SQL Server memory settings
Allocate CPU cores with an affinity mask
File system configuration

Part II: Deployment


Chapter 4 Install and configure SQL Server instances
and features
What to do before installing SQL Server
Decide on volume usage
Important SQL Server volume settings
SQL Server editions
Install a new instance
Plan for multiple SQL Server instances
Install SQL Server on Windows
Install common features
Log SQL Server Setup
Automate SQL Server Setup with
configuration files
SQL Server on Azure virtual machines
Post-installation server configuration
Post-installation checklist
Post-installation configuration of other features
SSISDB initial configuration and setup
SQL Server Reporting Services initial
configuration and setup
SQL Server Analysis Services initial
configuration and setup
Azure Synapse Link for SQL Server
Container orchestration with Kubernetes
Kubernetes support for SQL Server
Deploy SQL Server in containers
Get started with SQL Server on Kubernetes
Deploy SQL Server on Kubernetes
Review cluster health

Chapter 5 Install and configure SQL Server on Linux


What is Linux?
Differences between Windows and Linux
Linux distributions supported by SQL
Server
Considerations for installing SQL Server on Linux
Configure OS settings
Install SQL Server on Linux
Installation requirements
Download and install packages
Configure SQL Server on Linux
Use mssql-conf to set up and configure
SQL Server
Caveats of SQL Server on Linux
Missing SQL Server features on Linux

Chapter 6 Provision and configure SQL Server


databases
Add databases to a SQL Server instance
Create a database
Move existing databases
Upgrade database compatibility levels
Other considerations for migrating
databases
Database-scoped configurations
Database properties and options
Move and remove databases
Move user and system databases
Move databases within instances
Single-user mode

Chapter 7 Understand table features


Review table structures
General-purpose data types
Specialized data types
Data type precedence
Constraints
Sequence objects
User-defined data types and user-defined
types
Sparse columns
Computed columns
Special table types
System-versioned temporal tables
Memory-optimized tables
Graph tables
Store large binary objects
Understand FILESTREAM
FileTable
Table partitions
Horizontally partitioned tables and indexes
Vertical partitions
Capture modifications to data
Use change tracking
Use change data capture
Query change tracking and change data
capture
Compare change tracking, change data
capture, and temporal tables
Benefits of PolyBase for external data sources and
external tables
Unified data platform features
Install and configure PolyBase
More PolyBase examples, architectures
including S3 and URL queries
PolyBase examples with a generic ODBC
driver
Azure bulk operations examples

Part III: SQL Server management

Chapter 8 Maintain and monitor SQL Server


Detect, prevent, and respond to database
corruption
Set the database’s page verify option
Repair database data file corruption
Recover from database transaction log file
corruption
Database corruption in Azure SQL
Database
Maintain indexes and statistics
Change the fill factor when beneficial
Monitor index fragmentation
Maintain indexes
Manage database file sizes
Understand and find autogrowth events
Shrink database files
Monitor activity with DMOs
Observe sessions and requests
Understand wait types and wait statistics
Monitor with the SQL Assessment API
Use Extended Events
View Extended Events data
Use Extended Events to capture deadlocks
Use Extended Events to detect autogrowth
events
Use Extended Events to detect page splits
Secure Extended Events
Capture performance metrics with DMOs and data
collectors
Query performance metrics with DMVs
Capture performance metrics with
Performance Monitor
Monitor key performance metrics
Monitor key performance metrics in Linux
Monitor key performance metrics in Azure
portal
Protect important workloads with Resource
Governor
Configure the Resource Governor classifier
function
Configure Resource Governor resource
pools and workload groups
Monitor resource pools and workload
groups
Understand the SQL Server servicing model
Updated servicing model
Plan for the product support life cycle

Chapter 9 Automate SQL Server administration


Foundations of SQL Server automated
administration
Database Mail
SQL Server Agent
Maintain SQL Server
Basic care and feeding of SQL Server
Use SQL Server maintenance plans
Cover databases with the maintenance plan
Maintenance plan tasks
Maintenance plan report options
Build maintenance plans using the
Maintenance Plan designer in SSMS
Back up availability groups using a
secondary replica
Strategies for administering multiple SQL Servers
Master/Target servers for SQL Agent jobs
SQL Server Agent event forwarding
Policy-based management
Use PowerShell to automate SQL Server
administration
PowerShell basics
Install the PowerShell SQLServer module
Use PowerShell with SQL Server
Use PowerShell with availability groups

Chapter 10 Develop, deploy, and manage data


recovery
Prepare for data recovery
A disaster recovery scenario
Define acceptable data loss: RPO
Define acceptable downtime: RTO
Establish and use a runbook
Ransomware attacks
Understand different types of backups
An overview of SQL Server recovery
models
Full backups
Differential backups
The backup chain
File and filegroup backups
Additional backup options and
considerations
Understand backup devices
Back up to disk
Back up to URL
Backup and media sets
Back up to S3-compatible storage
Create and verify backups
Create backups
Verify backups
Restore a database
Restore a database using a full backup
Restore a database with differential and log
backups
Restore a database to a point in time
Restore a database piecemeal
Define a recovery strategy
A sample recovery strategy for our DR
scenario
Recovery strategies for hybrid and cloud
environments

Chapter 11 Implement high availability and disaster


recovery
Overview of high-availability and disaster-recovery
technologies
Compare HA and DR technologies
Understand log shipping
Understand the capabilities of failover
clustering
Understand the capabilities of availability
groups
Configure failover cluster instances
Understand FCI quorum
Configure a SQL Server FCI
Patch a failover cluster
Design availability groups solutions
Compare different cluster types
Create WSFC for use with availability
groups
Understand the database mirroring
endpoint
Recent improvements to availability groups
Choose the correct secondary replica
availability mode
Understand the impact of secondary
replicas on performance
Understand failovers in availability groups
Seeding options when adding replicas
Additional actions after creating an
availability group
Read secondary database copies
Query Store on replicas
Implement a hybrid availability group
topology
Understand the Azure SQL Managed Instance link
feature
Failover and failback to Azure SQL
Managed Instance with database portability
Provision and scale the Azure SQL
Managed Instance link feature
Failover and failback tooling and
automation
Configure availability groups in SQL Server on
Linux
Understand the differences between
Windows and Linux clustering
Set up an availability group in SQL Server
on Linux
Administer availability groups
Analyze DMVs for availability groups
Analyze wait types for availability groups
Analyze Extended Events for availability
groups
Alerts for availability groups

Part IV: Security

Chapter 12 Administer instance and database security


and permissions
Understand authentication modes
Windows Authentication
SQL Server Authentication
Azure Active Directory
Advanced types of server principals
Authentication to SQL Server on Linux
Contained database authentication
Grasp security principals
The basics of privileges
Configure login server principals
Database principals
Understand permissions and authorization
Permissions for controlling Data Definition
Language and Data Manipulation Language
How permissions accumulate
Understand authorization
Perform common security administration tasks
Orphaned SIDs
Create login with known SID
Migrate SQL Server logins and permissions
Dedicated administrator connection

Chapter 13 Protect data through classification,


encryption, and auditing
Privacy in the modern era
General Data Protection Regulation
(GDPR)
Microsoft Purview overview
Introduction to security principles and protocols
Secure your environment with defense in
depth
The difference between hashing and
encryption
A primer on protocols and transmitting data
Digital certificates
Protect the data platform
Secure the network with TLS
Data protection from the OS
The encryption hierarchy in detail
Use EKM modules with SQL Server
Master keys in the encryption hierarchy
Encrypt data with TDE
Protect sensitive columns with Always
Encrypted
Row-level security
Dynamic data masking
Protect Azure SQL Database with Microsoft
Defender for SQL
Ledger overview
Immutable storage
Ledger verification
Ledger considerations and limitations
Data storage requirements
Types of ledger tables
Audit with SQL Server and Azure SQL Database
SQL Server Audit
Auditing with Azure SQL
Secure Azure infrastructure as a service
Network security groups
User-defined routes and IP forwarding
Additional Azure networking security
features

Part V: Performance

Chapter 14 Performance tune SQL Server


Understand isolation levels and concurrency
Understand how concurrent sessions
become blocked
Change the isolation level
Understand and handle common
concurrency scenarios
Understand row version-based concurrency
Understand on-disk versus memory-
optimized concurrency
Understand durability settings for performance
Delayed durability database options
How SQL Server executes a query
Understand the query execution process
View execution plans
Understand execution plans
Understand parameterization and
parameter sniffing
Explore the procedure cache
Understand parallelism
Use advanced engine features to tune queries
Internal improvements in SQL Server 2022
Recent improvements to tempdb
Leverage the Query Store feature
Query Store hints
Automatic plan correction
Intelligent query processing

Chapter 15 Understand and design indexes


Design clustered indexes
Choose a proper rowstore clustered index
key
The case against intentionally designing
heaps
Understand the
OPTIMIZE_FOR_SEQUENTIAL_KEY
feature
Design rowstore nonclustered indexes
Understand nonclustered index design
Create filtered nonclustered indexes
Understand the missing indexes feature
Understand and provide index usage
Understand columnstore indexes
Design columnstore indexes
Understand batch mode
Understand the deltastore of columnstore
indexes
Demonstrate the power of columnstore
indexes
Understand indexes in memory-optimized tables
Understand hash indexes for memory-
optimized tables
Understand nonclustered indexes for
memory-optimized tables
Understand index statistics
Automatically create and update statistics
Manually create statistics for on-disk tables
Understand statistics on memory-optimized
tables
Understand statistics on external tables
Understand other types of indexes
Understand full-text indexes
Understand spatial indexes
Understand XML indexes

Part VI: Cloud

Chapter 16 Design and implement hybrid and Azure


database infrastructure
Cloud computing and Microsoft Azure
Database as a service
Managing Azure with the Azure portal and
PowerShell 7
Azure governance
Cloud-first
Resource scalability
Networking in Azure
Cloud models and SQL Server
Infrastructure as a service
Platform as a service
Hybrid cloud with Azure
Cloud security
Other data services in Azure
Azure Synapse Analytics
Non-relational Azure data offerings
Third-party fully managed data platforms

Chapter 17 Provision Azure SQL Database


Provision an Azure SQL Database logical server
Create an Azure SQL Database server
using the Azure portal
Create a server using PowerShell
Establish a connection to your server
Delete a server
Provision a database in Azure SQL Database
Create a database using the Azure portal
Create a database using PowerShell
Create a database using Azure CLI
Create a database using T-SQL
Scale up or down
Provision a named replica for a Hyperscale
database
Provision an elastic pool
Manage database space
Security in Azure SQL Database
Security features shared with SQL Server
2022
Server- and database-level firewall
Integrate with virtual networks
Azure Private Link for Azure SQL Database
Control access using Azure AD
Use Azure role-based access control
Audit database activity
Microsoft Defender for SQL
Prepare Azure SQL Database for disaster recovery
Understand default disaster recovery
features
Manually export database contents
Enable zone-redundant configuration
Configure geo-replication
Set up failover groups
Use Azure Backup for long-term backup
retention

Chapter 18 Provision Azure SQL Managed Instance


What is Azure SQL Managed Instance?
Differences between SQL Server and Azure
SQL Managed Instance
Create a SQL managed instance
Select a service tier and service objective
Use the Azure portal to provision a SQL
managed instance
Use PowerShell to provision a SQL
managed instance
Delete a SQL managed instance
Establish a connection to a SQL managed instance
Create the endpoints via the Azure portal
Create a VPN gateway via PowerShell
Network requirements for SQL managed
instances
Migrate data to Azure SQL Managed Instance
Link feature for Azure SQL Managed
Instance
Azure Data Migration Service
Migrate with backup and restore
Managed instance pools
Azure SQL Managed Instance administration
features
High availability
Replication
Scale up or down
Monitor SQL managed instances
Another random document with
no related content on Scribd:
Section 3. Information about the Project
Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many small
donations ($1 to $5,000) are particularly important to maintaining tax
exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.

Project Gutenberg™ eBooks are often created from several printed


editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like