20765C ENU Companion
20765C ENU Companion
20765C ENU Companion
20765C
Provisioning SQL Databases
ii Provisioning SQL Databases
Information in this document, including URL and other Internet Web site references, is subject to change
without notice. Unless otherwise noted, the example companies, organizations, products, domain names,
e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with
any real company, organization, product, domain name, e-mail address, logo, person, place or event is
intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the
user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in
or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical,
photocopying, recording, or otherwise), or for any purpose, without the express written permission of
Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property
rights covering subject matter in this document. Except as expressly provided in any written license
agreement from Microsoft, the furnishing of this document does not give you any license to these
patents, trademarks, copyrights, or other intellectual property.
The names of manufacturers, products, or URLs are provided for informational purposes only and
Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding
these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a
manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links
may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not
responsible for the contents of any linked site or any link contained in a linked site, or any changes or
updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission
received from any linked site. Microsoft is providing these links to you only as a convenience, and the
inclusion of any link does not imply endorsement of Microsoft of the site or the products contained
therein.
© 2018 Microsoft Corporation. All rights reserved.
Module 1
SQL Server Components
Contents:
Lesson 1: Introduction to the SQL Server Platform 2
Lesson 1
Introduction to the SQL Server Platform
Contents:
Question and Answers 3
Demonstration: Identify the Edition and Version of a Running SQL Server
Instance 4
SQL Server Components 1-3
Items
Answer:
2. On the taskbar, click the Microsoft SQL Server Management Studio 17 shortcut.
6. In Object Explorer, point to the server name (MIA-SQL) and show that the server number is in
parentheses after the server name.
7. In Object Explorer, right-click the server name MIA-SQL, and then click Properties.
8. On the General page, note Product and Version properties are visible, and then click Cancel.
9. Start File Explorer. Navigate to C:\Program Files\Microsoft SQL
Server\MSSQL14.MSSQLSERVER\MSSQL\Log.
13. The first entry in the file displays the version name, version number and edition, amongst other
information. Close Notepad.
14. In SQL Server Management Studio, select the code under the comment Method 4, and then click
Execute.
15. Select the code under the comment Method 5, and then click Execute.
16. Close SQL Server Management Studio without saving changes.
SQL Server Components 1-5
Lesson 2
Overview of SQL Server Architecture
Contents:
Question and Answers 6
Demonstration: CPU and Memory Configurations in SSMS 6
1-6 Provisioning SQL Databases
Steps
Query Execution
Layer
Storage Engine
SQLOS
Answer:
Steps
1 Query
Execution Layer
2 Storage Engine
3 SQLOS
8. Select the Advanced tab and in the Parallelism group, review the default values for Cost Threshold
for Parallelism and for Max Degree of Parallelism.
9. Select the Memory tab and review the default memory configurations. Click Cancel to close the
Server Properties window.
Lesson 3
SQL Server Services and Configuration Options
Contents:
Question and Answers 8
1-8 Provisioning SQL Databases
( ) Shared Memory
( ) Named Pipes
( ) TCP/IP
Answer:
( ) Named Pipes
(√) TCP/IP
SQL Server Components 1-9
Answer: These choices are determined by the context of the environment where you are
deploying SQL Server.
Answer: This answer is determined by the context of the environment where you are deploying
SQL Server.
Installing SQL Server 2-1
Module 2
Installing SQL Server
Contents:
Lesson 1: Considerations for Installing SQL Server 2
Lesson 1
Considerations for Installing SQL Server
Contents:
Question and Answers 3
Demonstration: Using SQLIOSim 3
Demonstration: Using Diskspd 3
Installing SQL Server 2-3
( ) Diskspd
( ) SQLIOSim
Answer:
(√) Diskspd
( ) SQLIOSim
2. In the D:\Demofiles\Mod02 folder, right-click Setup.cmd, and then click Run as administrator.
3. In the User Account Control dialog box, click Yes, and wait for the script to finish.
15. In File Explorer, go to D:\, and open sqliosim.log.xml with Office XML Handler.
16. Review the test results in the XML file, and then close the file without saving changes.
4. In Windows PowerShell, at the command prompt, type the following, and then press ENTER:
cd D:\Demofiles\Mod02\Diskspd-v2.0.17\amd64fre
6. Wait for the command to complete, and then review the output of the tool.
Lesson 2
tempdb Files
Contents:
Question and Answers 6
2-6 Provisioning SQL Databases
( ) True
( ) False
Answer:
( ) True
(√) False
Installing SQL Server 2-7
Lesson 3
Installing SQL Server
Contents:
Question and Answers 8
2-8 Provisioning SQL Databases
Items
1 Installation
Wizard
2 Windows
Update
3 Command
Prompt
4 Command
Prompt with
a
configuration
file
5 PowerShell
Category 1 Category 2
Can be Cannot be
used to used to
install SQL install SQL
Server Server
Installing SQL Server 2-9
Answer:
Category 1 Category 2
Installation Windows
Wizard Update
Command
Prompt
Command
Prompt with
a
configuration
file
PowerShell
2-10 Provisioning SQL Databases
Lesson 4
Automating Installation
Contents:
Question and Answers 11
Demonstration: Reviewing an Unattended Installation File 11
Installing SQL Server 2-11
( ) InstallationFile.ini
( ) ConfigurationFile.ini
( ) Wizard.ini
( ) Config.ini
Answer:
( ) InstallationFile.ini
(√) ConfigurationFile.ini
( ) Wizard.ini
( ) Config.ini
a. INSTANCEID
b. ACTION
c. FEATURES
d. QUIET
e. QUIETSIMPLE
f. INSTALLSHAREDDIR
g. INSTANCEDIR
h. INSTANCENAME
i. AGTSVCSTARTUPTYPE
j. SQLCOLLATION
k. SQLSVCACCOUNT
l. SQLSYSADMINACCOUNTS
m. TCPENABLED
5. Close Notepad.
Answer: Multiple instances can coexist on a single server, but you must consider the impact on
server resources. The workloads on each instance will compete for memory, CPU, and storage I/O
resources that can affect application performance.
Upgrading SQL Server to SQL Server 2017 3-1
Module 3
Upgrading SQL Server to SQL Server 2017
Contents:
Lesson 1: Upgrade Requirements 2
Lesson 1
Upgrade Requirements
Contents:
Question and Answers 3
Resources 3
Demonstration: Preparing for an Upgrade with Data Migration Assistant 3
Upgrading SQL Server to SQL Server 2017 3-3
Answer:
Resources
Distributed Replay Utility
Additional Reading: For more information on the SQL Server Profiler utility and SQL
Server Profiler traces, see course 20764: Administering a SQL Database Infrastructure.
3. When the script has completed, press any key to close the window.
4. Navigate to https://www.microsoft.com/en-us/download/details.aspx?id=42642.
5. In the Microsoft .NET Framework 4.5.2 (Offline Installer) page, ensure that English is selected,
then click Download.
9. Check I have read and accept the license terms, then click Install.
10. When prompted, restart the 20765-MIA-SQL-UPGRADE computer and log on again as
ADVENTUREWORKS\Student with a password of Pa55w.rd.
3-4 Provisioning SQL Databases
14. In the Microsoft Data Migration Assistant Setup window, click Next.
15. Select the I accept the terms in the License Agreement check box, and then click Next.
16. Select the I agree to the Privacy Policy check box, and then click Install.
17. In the User Account Control dialog box, click Yes, and then click Finish.
18. On the Start screen, type Microsoft Data Migration Assistant, and then click Microsoft Data
Migration Assistant.
19. In the Data Migration Assistant, on the left-hand side, click the + sign.
22. Ensure that Source server type and Target server type are both set to SQL Server.
23. Click Create.
24. In the Options pane, ensure that Select target version is set to SQL Server 2017 on Windows, and
that Compatibility Issues is selected, then click Next.
25. In the SERVER NAME box, type MIA-SQL, check that Authentication type is set to Windows
Authentication.
26. Check the Trust server certificate box and then click Connect.
27. In the Select sources pane, under the list of databases, check TSQL and MDS, and click Add.
29. When analysis is complete, in the left-hand pane under MIA-SQL (SQL Server 2014), click TSQL.
30. In the Compatibility 140 (1) blade, under Behavior changes (1), click SET ROWCOUNT used in
the context of DML statements such as INSERT, UPDATE, or DELETE.
31. Show the students the output from this check and the implications when using SET ROWCOUNT
statements.
Lesson 2
Upgrade of SQL Server Services
Contents:
Question and Answers 6
Resources 7
Demonstration: Carry Out an In-Place Upgrade 7
3-6 Provisioning SQL Databases
Items
1 Database
Engine
2 Integration
Services
3 Reporting
Services
4 SQL Server
management
tools
5 Analysis
Services
6 Master Data
Services
Category 1 Category 2
Answer:
Category 1 Category 2
Database Integration
Engine Services
Reporting SQL Server
Services management
Analysis tools
Services
Master
Data
Services
Resources
Additional Reading: For more information on working with database backups, data files,
and log files, see the module Working with Databases later in this course, and course 20764:
Administering a SQL Database Infrastructure.
4. In SQL Server Installation Center, click Installation, and then click Upgrade from a previous version
of SQL Server.
5. On the Product Key page, click Next.
6. On the License Terms page, select I accept the license terms, and then click Next.
7. On the Product Updates page, click Next. Any error relating to a failure to search for updates
through Windows Update can be ignored.
8. On the Select Instance page, set the value of the Instance to upgrade box to MSSQLSERVER, and
then click Next.
9. On the Reporting Services Migration page, check Uninstall Reporting Services, then click Next.
3-8 Provisioning SQL Databases
14. The demonstration stops at this point because you cannot complete the upgrade with an Evaluation
version of SQL Server.
15. On the Feature Rules page, click Cancel, and then click Yes to Cancel the installation.
Lesson 3
Side-by-Side Upgrade: Migrating SQL Server Data and
Applications
Contents:
Question and Answers 10
Resources 10
Demonstration: Scripting SQL Server Logins 10
3-10 Provisioning SQL Databases
( ) True
( ) False
Answer:
(√) True
( ) False
Resources
Migrating SQL Server Databases
Additional Reading: For more information on installing SQL Server 2017, see Module 2 of
this course: Installing SQL Server.
6. Select the code under the comment Demonstration - Login and User, and then click Execute.
7. Select the code under the comment Step 1, and then click Execute.
8. Select the code under the comment Step 2, and then click Execute.
9. Select the code under the comment Step 3, and then click Execute.
10. Select the code under the comment Step 4, and then click Execute.
12. Right-click DemoLogin1, point to Script Login as, point to CREATE To, and then click New Query
Editor Window. If DemoLogin1 is not visible, right-click the Logins node and click Refresh.
Upgrading SQL Server to SQL Server 2017 3-11
13. Examine the generated script. Note that the password is not correct, and then close the tab.
14. Select the code under the comment Step 6, and then click Execute.
Answer: The reportuser login was created with the same SID as it had on the source SQL Server
2014 instance.
Working with Databases 4-1
Module 4
Working with Databases
Contents:
Lesson 1: Introduction to Data Storage with SQL Server 2
Lesson 1
Introduction to Data Storage with SQL Server
Contents:
Question and Answers 3
Working with Databases 4-3
“Disks are stored in an enclosure and connected to the server by a RAID controller.”
( ) SAN
( ) DAS
Answer:
( ) SAN
Question: When determining file placement and the number of files, what should you consider?
Answer:
Lesson 2
Managing Storage for System Databases
Contents:
Question and Answers 5
Demonstration: Moving tempdb Files 6
Working with Databases 4-5
( ) master
( ) adventureworks
( ) model
( ) tempdb
( ) resource
Answer:
( ) master
(√) adventureworks
( ) model
( ) tempdb
( ) resource
Put the following steps in order by numbering each to indicate the correct order.
Steps
Answer:
Steps
2. In the D:\Demofiles\Mod04 folder, run Setup.cmd as Administrator. Click Yes when prompted.
3. Start SQL Server Management Studio and connect to the MIA-SQL database engine using Windows
authentication.
4. In Object Explorer, expand Databases, expand System Databases, and then right-click tempdb and
click Properties.
5. In the Database Properties - tempdb dialog box, on the Files page, note the current files and their
location, and then click Cancel.
7. View the code in the script, and then click Execute. Note the message that is displayed after the code
has run.
8. View the contents of T:\ and note that no files have been created in that location, because the SQL
Server service has not yet been restarted.
9. In Object Explorer, right-click MIA-SQL and click Restart. Click Yes when prompted.
10. If the User Account prompt is displayed, click Yes to allow SQL Server to make changes. When
prompted to allow changes, to restart the service, and to stop the dependent SQL Server Agent
service, click Yes.
Working with Databases 4-7
11. View the contents of T:\ and note that the tempdb.mdf and templog.ldf files have been moved to
this location.
12. Keep SQL Server Management Studio open for the next demonstration.
4-8 Provisioning SQL Databases
Lesson 3
Managing Storage for User Databases
Contents:
Question and Answers 9
Demonstration: Creating Databases 10
Working with Databases 4-9
( ) A user database must have at least one primary data file and one log file.
( ) The default file extension for the primary data file is .mdf.
( ) Logical file names for data and log files do not have to be unique.
Answer:
( ) A user database must have at least one primary data file and one log file.
( ) The default file extension for the primary data file is .mdf.
( ) To delete a database, you use the DROP DATABASE Transact-SQL statement.
(√) Logical file names for data and log files do not have to be unique.
( ) True
( ) False
Answer:
( ) True
(√) False
Question: When expanding a database, you must increase its size by at least 1 MB.
( ) True
( ) False
Answer:
(√) True
( ) False
Question: What Transact-SQL would you use to modify the default filegroup in the Customers database
to the Transactions filegroup?
Answer:
1. Ensure that you have completed the previous demonstration. If not, start the 20765C-MIA-DC and
20765C-MIA-SQL virtual machines, log on to 20765C-MIA-SQL as ADVENTUREWORKS\Student
with the password Pa55w.rd, and run D:\Demofiles\Mod04\Setup.cmd as Administrator.
2. If SQL Server Management Studio is not open, start it and connect to the MIA-SQL database engine
using Windows authentication.
o DemoDB1:
o Path: D:\Demofiles\M od04
o DemoDB1_log:
o Path: D:\Demofiles\Mod04
7. Expand the Databases folder, right-click DemoDB1, and then click Properties.
8. On the Options tab, review the database options, and then click Cancel.
1. In SQL Server Management Studio, open the CreatingDatabases.sql script file from the
D:\Demofiles\Mod04 folder.
2. Select the code under the comment Create a database and click Execute to create a database
named DemoDB2.
3. Select the code under the comment View database info and click Execute. View the information
that is returned.
4. Keep SQL Server Management Studio open for the next demonstration.
Working with Databases 4-11
Lesson 4
Moving and Copying Database Files
Contents:
Question and Answers 12
Demonstration: Detaching and Attaching a Database 12
4-12 Provisioning SQL Databases
( ) MOVE DATABASE
( ) MODIFY FILE
( ) UPDATE PATH
( ) ALTER PATH
( ) ALTER DATABASE
Answer:
( ) MOVE DATABASE
( ) MODIFY FILE
( ) UPDATE PATH
( ) ALTER PATH
(√) ALTER DATABASE
Question: True or false? Databases that are configured for replication, mirrored, or in a suspect state,
cannot be detached.
( ) True
( ) False
Answer:
(√) True
( ) False
4. In the Detach Database dialog box, select Drop Connections and Update Statistics, and then click
OK.
5. View the M:\Data and L:\Logs folders and verify that the DemoDB2.mdf and DemoDB2.ldf files
have not been deleted.
Attach a Database
1. In SQL Server Management Studio, in Object Explorer, in the Connect drop-down list, click Database
Engine.
3. In Object Explorer, under MIA-SQL\SQL2, expand Databases and view the databases on this
instance.
6. In the Locate Database Files - MIA-SQL\SQL2 dialog box, select the M:\Data\DemoDB2.mdf
database file, then click OK.
7. In the Attach Databases dialog box, after you have added the master databases file, note that all of
the database files are listed, then click OK.
8. In Object Explorer, under MIA-SQL\SQL2, under Databases, verify that DemoDB2 is now listed.
4-14 Provisioning SQL Databases
Lesson 5
Configuring the Buffer Pool Extension
Contents:
Question and Answers 15
Demonstration: Configuring the Buffer Pool Extension 15
Working with Databases 4-15
( ) SSD devices are often more cost effective than adding physical memory.
Answer:
(√) SSD devices are cheaper than conventional hard disk storage.
( ) Improves performance for read-heavy OLTP workloads.
( ) SSD devices are often more cost effective than adding physical memory.
1. Ensure that you have completed the previous demonstration. If not, start the MT17B-WS2016-NAT,
20765C-MIA-DC, and 20765C-MIA-SQL virtual machines, log on to 20765C-MIA-SQL as
ADVENTUREWORKS\Student with the password Pa55w.rd, and then run
D:\Demofiles\Mod04\Setup.cmd as Administrator.
2. If SQL Server Management Studio is not open, start it and connect to the MIA-SQL database engine
using Windows authentication.
4. Review the code under the comment Enable buffer pool extension, and note that it creates a buffer
pool extension file named MyCache.bpe on T:\. On a production system, this file location would
typically be on an SSD device.
5. Use File Explorer to view the contents of the T:\ folder and note that no MyCache.bpe file exists.
6. In SQL Server Management Studio, select the code under the comment Enable buffer pool
extension, then click Execute.
7. Use File Explorer to view the contents of the T:\ folder and note that the MyCache.bpe file has been
created.
8. Select the code under the comment View buffer pool extension details, click Execute, then review
the output in the Results tab and note that buffer pool extension is enabled.
9. Select the code under the comment Monitor buffer pool extension, click Execute, then review the
output in the Results tab.
4-16 Provisioning SQL Databases
1. In SQL Server Management Studio, select the code under the comment Disable buffer pool
extension, then click Execute.
2. Use File Explorer to view the contents of the T:\ folder and note that the MyCache.bpe file has been
deleted.
3. In SQL Server Management Studio, select the code under the comment View buffer pool extension
details again, and click Execute. Review the row in the Results tab, and note that the buffer pool
extension is disabled.
Review Question(s)
Question: Why is it typically sufficient to have one log file in a database?
Answer: Log files are written sequentially. If more than one log file exists, SQL Server writes them
in a circular manner, which doesn‘t provide any advantages for performance and availability.
Question: Why should only temporary data be stored in the tempdb system database?
Module 5
Performing Database Maintenance
Contents:
Lesson 1: Ensuring Database Integrity 2
Lesson 1
Ensuring Database Integrity
Contents:
Question and Answers 3
Resources 3
Demonstration: Using DBCC CHECKDB 3
Performing Database Maintenance 5-3
( ) DBCC CHECKTABLE
( ) DBCC CHECKALLOC
( ) DBCC CHECKCATALOG
Answer:
( ) DBCC CHECKTABLE
( ) DBCC CHECKALLOC
Answer: Yes, because no matter how well the technical architecture is functioning, there is always
the possibility that a system outage might compromise the integrity of your data.
The real strength of a relational database management system comes from storing each piece of
data in just one place within a normalized database. This means that a change to the data in one
location could have a ripple effect throughout your information stores, effectively reducing the
information back to data, and preventing it from becoming trusted information—because there
is no way of ensuring its complete integrity.
Backup and restore processes can present their own challenges: restoring a complete database
might be too time consuming or the transaction log might be corrupt. In disaster situations,
being able to recover some of the data quickly is often essential to a business.
Resources
DBCC CHECKDB Repair Options
Additional Reading: For more information about backing up and restoring a SQL Server
database, see course 20754B: Administering a SQL Database Infrastructure.
2. In the D:\Demofiles\Mod05 folder, run Setup.cmd as Administrator. Click Yes when prompted.
3. Start Microsoft SQL Server Management Studio and connect to the MIA-SQL database engine
instance using Windows authentication.
5. Select the code under the comment -- Run DBCC CHECKDB with default options and click
Execute. This checks the integrity of the AdventureWorks database and provides maximum
information.
6. Select the code under the comment -- Run DBCC CHECKDB without informational messages and
click Execute. This code checks the integrity of the AdventureWorks database and only displays
messages if errors were present.
7. Select the code under the comment -- Run DBCC CHECKDB against CorruptDB and click Execute.
This checks the integrity of the CorruptDB database and identifies some consistency errors in the
dbo.Orders table in this database. The last line of output tells you the minimum repair level required.
8. Select the code under the comment -- Try to access the Orders table and click Execute. This
attempts to query the dbo.Orders table in the CorruptDB database, and returns an error because of
a logical consistency issue.
9. Select the code under the comment -- Access a specific order and click Execute. This succeeds,
indicating that only “some data pages are affected by the inconsistency issue”.
10. Select the code under the comment -- Repair the database and click Execute. Note that this
technique is a last resort, when no valid backup is available. There is no guarantee of logical
consistency in the database, such as the checking of foreign key constraints. These will need checking
after running this command.
11. Select the code under the comment -- Access the Orders table and click Execute. This succeeds,
indicating that the physical consistency is re-established.
12. Select the code under the comment -- Check the internal database structure and click Execute.
Note that no error messages appear, indicating that the database structure is now consistent.
13. Select the code under the comment -- Check data loss and click Execute. Note that a number of
order details records have no matching order records. The foreign key constraint between these
tables originally enforced a relationship, but some data has been lost.
Lesson 2
Maintaining Indexes
Contents:
Question and Answers 6
Demonstration: Maintaining Indexes 6
5-6 Provisioning SQL Databases
( ) You are looking at an index, on a transactional table, with fragmentation of less than 30 percent.
Answer:
3. Select the code under the comment -- Create a table with a primary key and click Execute. This
creates a table with a primary key, which by default creates a clustered index on the primary key field.
4. Select the code under the comment -- Insert some data into the table and click Execute. This
inserts 10,000 rows into the table.
5. Select the code under the comment -- Check fragmentation and click Execute. In the results, note
the avg_fragmentation_in_percent and avg_page_space_used_in_percent values for each index level.
6. Select the code under the comment -- Modify the data in the table and click Execute. This updates
the table.
7. Select the code under the comment -- Re-check fragmentation and click Execute. In the results,
note that the avg_fragmentation_in_percent and avg_page_space_used_in_percent values for each
index level have changed because the data pages have become fragmented.
8. Select the code under the comment -- Rebuild the table and its indexes and click Execute. This
rebuilds the indexes on the table.
9. Select the code under the comment -- Check the fragmentation again and click Execute. In the
results, note that the avg_fragmentation_in_percent and avg_page_space_used_in_percent values for
each index level indicate less fragmentation.
Lesson 3
Automating Routine Maintenance Tasks
Contents:
Question and Answers 8
Demonstration: Configuring a Database Maintenance Plan 9
5-8 Provisioning SQL Databases
Items
1 Use multiple
data
maintenance
plans
combined
with SQL
Server Agent
scheduled
jobs
2 Use
Transact-SQL
statements
to
implement
maintenance
tasks
Answer:
2. In Object Explorer, under MIA-SQL, expand Management, right-click Maintenance Plans, and click
Maintenance Plan Wizard.
3. In the SQL Server Maintenance Plan Wizard, click Next.
4. On the Select Plan Properties page, in the Name box, type Maintenance Plan for Optimization of
AdventureWorks Database, and then click Next.
5. On the Select Maintenance Tasks page, select the following tasks, and then click Next:
o Shrink Database
o Rebuild Index
o Update Statistics
6. On the Select Maintenance Task Order page, change the order of the tasks to Rebuild Index,
Shrink Database, and Update Statistics, and then click Next.
7. On the Define Rebuild Index Task page in the Databases list, click AdventureWorks, and then
click OK to close the drop-down list box. Click Next.
8. On the Define Shrink Database Task page, in the Databases list, click AdventureWorks, click OK
to close the drop-down list box, and then click Next.
9. On the Define Update Statistics page, in the Databases list, click AdventureWorks. Click OK to
close the drop-down list box, and then click Next.
10. On the Select Report Options page, review the default settings, and then click Next.
11. On the Complete the Wizard page, click Finish to create the Maintenance Plan. Wait for the
operation to complete, and then click Close.
5-10 Provisioning SQL Databases
Defragment your indexes when necessary, but if they get beyond about 30 percent fragmentation,
consider rebuilding instead.
Update statistics on a schedule if you don’t want it to occur during normal operations.
Answer: There is a substantial difference in the recovery requirements of the two types of
system. It is much more likely that you will have to use Emergency mode to recover changes in
an OLTP system rather than an OLAP system.
Answer: No.
Database Storage Options 6-1
Module 6
Database Storage Options
Contents:
Lesson 1: SQL Server Storage Performance 2
Lesson 1
SQL Server Storage Performance
Contents:
Question and Answers 3
Demonstration: Moving tempdb Files 3
Database Storage Options 6-3
Data files
tempdb
Answer: There is no correct answer—much will depend on database usage and budget.
2. In the D:\Demofiles\Mod06 folder, run Setup.cmd as Administrator. Click Yes when prompted.
3. Start SQL Server Management Studio and connect to the MIA-SQL database engine using Windows
authentication.
4. In Object Explorer, expand Databases, expand System Databases, right-click tempdb, and then click
Properties.
5. In the Database Properties dialog box, on the Files page, note the current files and their location.
Then click Cancel.
7. View the code in the script, and then click Execute. Note the message that is displayed after the code
has run.
8. View the contents of D:\ and note that no files have been created in that location, because the SQL
Server service has not yet been restarted.
9. In Object Explorer, right-click MIA-SQL, and then click Restart. When prompted, click Yes.
10. In the Microsoft SQL Server Management Studio dialog boxes, when prompted to allow changes,
to restart the service, and to stop the dependent SQL Server Agent service, click Yes.
11. View the contents of D:\ and note that the tempdb MDF and LDF files have been moved to this
location.
12. Keep SQL Server Management Studio open for the next demonstration.
6-4 Provisioning SQL Databases
Lesson 2
SMB Fileshare
Contents:
Question and Answers 5
Demonstration: Storing a Database on an SMB Fileshare 6
Database Storage Options 6-5
Answer:
( ) CREATE DATABASE [Sales]
ON PRIMARY
( NAME = N'Sales_Data', FILENAME = N'\\SMBServer\d$\SMBShare\Sales_data.mdf' )
LOG ON
( NAME = N'Sales_Log', FILENAME = N'\\SMBServer\d$\SMBShare\Sales_Log.ldf')
GO
2. Open File Explorer and navigate to the D:\ drive, right-click the smbshare folder, and then click
Properties.
3. In the smbshare Properties dialog box, on the Sharing tab, in the Network File and Folder
Sharing section, note that this folder is shared with the network path \\MIA-SQL\smbshare, and
then click Cancel.
4. In SQL Server Management Studio, open the file SMBDemo.sql located in the D:\Demofiles\Mod06
folder and execute the code it contains.
5. In File Explorer, navigate to the D:\smbshare folder and note the database files have been created.
Lesson 3
SQL Server Storage in Microsoft Azure
Contents:
Question and Answers 8
6-8 Provisioning SQL Databases
( ) Putting data files in Azure will not help because SQL Server data files in Azure take longer to back up
because the data is sourced from the Internet.
Answer:
( ) Putting data files in Azure will not help because SQL Server data files in Azure take longer to
back up because the data is sourced from the Internet.
Database Storage Options 6-9
Lesson 4
Stretch Database
Contents:
Question and Answers 10
6-10 Provisioning SQL Databases
Answer:
Module 7
Planning to Deploy SQL Server on Microsoft Azure
Contents:
Lesson 1: SQL Server on Virtual Machines and Azure SQL Database 2
Lesson 1
SQL Server on Virtual Machines and Azure SQL
Database
Contents:
Question and Answers 3
Demonstration: Provisioning an Azure Virtual Machine 3
Planning to Deploy SQL Server on Microsoft Azure 7-3
( ) True
( ) False
Answer:
( ) True
(√) False
3. Sign in to the Azure portal with your Azure Pass or Microsoft Account credentials.
4. In the Azure portal, click New, then in the Search box, type SQL Server 2017.
6. In the SQL Server 2017 Enterprise Windows Server 2016 pane, in the Select a deployment model
box, click Resource Manager, and then click Create.
7. On the Basics blade, in the Name box, type a name for your server of up to 15 characters. This must
be unique throughout the whole Azure service, so cannot be specified here. A suggested format is
sql2017vm-<your initials><one or more digits>. For example, sql2017vm-js123. Keep a note of
the name you have chosen.
11. Change the value of the Location box to a region near your current geographical location, and click
OK.
12. In the Choose a size blade, click View all then click DS11 Standard, and then click Select.
15. On the Summary blade, click Create. Deployment may take some time to complete.
16. When deployment is complete, click Virtual machines, then click the name of the machine you
created in step 7.
17. In the server name blade, click Connect, then click Open.
19. In the Windows Security dialog box, click More choices, then click Use a different account.
20. In the User name box, type \demoAdmin, in the Password box, type Pa55w.rd1234, and then click
OK.
7-4 Provisioning SQL Databases
23. Close the Remote Desktop connection, and then delete the Azure Virtual Machine.
Planning to Deploy SQL Server on Microsoft Azure 7-5
Lesson 2
Azure Storage
Contents:
Question and Answers 6
7-6 Provisioning SQL Databases
( ) You can choose the type of virtual machine based on CPU, memory, and storage capacity.
( ) You can delete an Azure virtual machine when you no longer need it.
Answer:
( ) You can delete an Azure virtual machine when you no longer need it.
Planning to Deploy SQL Server on Microsoft Azure 7-7
Lesson 3
Azure SQL Server Authentication
Contents:
Question and Answers 8
Resources 8
7-8 Provisioning SQL Databases
Answer: Security is a common concern when moving data to the cloud. Azure SQL Database
offers a range of security options including encryption and auditing, in addition to the
authentication and authorization features that are familiar to SQL Server database administrators.
When coupled with the stringent physical security that is employed at Azure data centers, there is
a case that data is more secure in the cloud, rather than less secure.
A common concern that Azure security features do not address includes delegating responsibility
for data protection to a third-party organization.
Resources
Security Overview of Azure SQL Database
Best Practice: Grant users the least permissions necessary. Security is often a trade-off
between convenience and protecting data. Grant the least permissions necessary for users to
complete their work, and grant additional permissions temporarily for exceptional tasks.
Planning to Deploy SQL Server on Microsoft Azure 7-9
Lesson 4
Deploying Databases in Azure SQL Database
Contents:
Question and Answers 10
Demonstration: Provisioning a Database in Azure SQL Database 10
Demonstration: Connecting to a Database in Azure SQL Database 11
7-10 Provisioning SQL Databases
Answer:
( ) A database transaction unit is a measure of CPU performance.
Add-AzureRmAccount
When prompted press y, and then press Enter. When the sign-in screen appears, use the same email
and password you use to sign in to the Azure portal. If you have already linked your Azure account
to PowerShell on this VM, use the command:
Login-AzureRMAccount
3. Use the subscription Id returned in the output of the previous step and run the following cmdlet:
(replace <your subscription id> with the GUID value returned by the previous step.)
4. Run the following cmdlet to return the list of Azure data center locations supporting SQL Database:
5. Run the following cmdlet to create a resource group. Substitute a location near your current
geographical location from the result returned by the previous step for <location>:
6. Run the following cmdlet to create a server in the new resource group. Substitute the location used in
the previous step for <location>. Substitute a unique server name for <your server name>; This must
be unique throughout the whole Azure service, so cannot be specified here. A suggested format is
sql2017ps-<your initials><one or more digits>. For example, sql2017ps-js123.
In the credential request dialog box, type the User name psUser and the password Pa55w.rd. This
step may take a few minutes to complete.
7. Run the following cmdlets separately to create a firewall rule to allow your current client to connect
to the server. Substitute the server name created in the previous step for <your server name>.
Substitute your current external IP address for <your external ip>. You can get your current external
IP address from the Azure Portal (see the value returned by the "Add Client IP" button on the firewall
for an existing server), or from third party services such as Google (search for "what is my ip") or
www.whatismyip.com:
8. Run the following cmdlet to create a database on the new server. Substitute the server name created
in a previous step for <your server name>.
3. Click SQL Databases, then click TestPSDB. Note the value of Server name, and then click Show
database connection strings.
5. In the Connect to Server dialog box, type the server name noted in the previous step (it will take the
form <your server name>.database.windows.net).
6. Set Authentication to SQL Server Authentication. In the Login box, type psUser, in the Password:
box, type Pa55w.rd, and then click Connect.
7. In Object Explorer, expand the Databases node to show the TestPSDB database.
12. Open Windows PowerShell, and then type the command below 3. Open Windows PowerShell
and type the following command into the Windows PowerShell window, replacing <your server
name> in the command with the server name used on step 3.
13. At the Password prompt, type Pa55w.rd, and then press Enter.
14. Close PowerShell, close SSMS without saving any changes, and then close Internet Explorer.
7-12 Provisioning SQL Databases
Review Question(s)
Question: Are Azure database services suitable for your organization?
Is Azure SQL Database or SQL Server on Azure virtual machines more suitable for you?
Module 8
Migrating Databases to Azure SQL Database
Contents:
Lesson 1: Database Migration Testing Tools 2
Lesson 1
Database Migration Testing Tools
Contents:
Question and Answers 3
Demonstration: Test Compatibility of a SQL Server Database with Azure SQL
Database 3
Migrating Databases to Azure SQL Database 8-3
Answer: This method does not test for Azure SQL Database compatibility because you did not
set the target platform for the project to Microsoft Azure SQL Database V12. If you set this
property and rebuild the project, compatibility issues will be listed. If no issues are listed, you can
proceed to migrate the database into Azure SQL Database.
4. Start a command prompt. Type the following command, and then press Enter:
Notepad D:\Demofiles\Mod08\ExportReport.txt
7. Examine the contents of the text file, and then close Notepad.
Lesson 2
Database Migration Compatibility Issues
Contents:
Question and Answers 5
Migrating Databases to Azure SQL Database 8-5
Answer: Azure datacenters are designed to provide high availability and resilience. They might
provide the same or higher availability as database mirroring in a less well-designed
infrastructure. However, to ensure the highest levels of availability in Azure SQL Database, use
active geo-replication.
8-6 Provisioning SQL Databases
Lesson 3
Migrating an On-Premises Database to an Azure SQL
Database
Contents:
Question and Answers 7
Demonstration: Migrate a SQL Server Database to Azure SQL Database with
BACPAC 7
Migrating Databases to Azure SQL Database 8-7
( ) True
( ) False
Answer:
( ) True
(√) False
3. Type the following command to import the database to Azure SQL Database. Substitute <your server
name> with the name of the Azure server hosting the target database:
4. Verify that the import has completed successfully by connecting to the Azure SQL server <your
server name. database.windows.net> using SSMS, then expanding the database TestPSDB and
showing the tables that now exist.
5. Close SSMS, and then close the command prompt.
8-8 Provisioning SQL Databases
Review Question(s)
Question: Are Azure database services suitable for your organization?
Is Azure SQL Database or SQL Server on Azure VMs more suitable for you?
Module 9
Deploying SQL Server on a Microsoft Azure Virtual Machine
Contents:
Lesson 1: Deploying SQL Server on Azure Virtual Machines 2
Lesson 1
Deploying SQL Server on Azure Virtual Machines
Contents:
Question and Answers 3
Demonstration: Provisioning an Azure Virtual Machine 3
Deploying SQL Server on a Microsoft Azure Virtual Machine 9-3
Answer: Use an image from the Azure Virtual Machine Gallery that includes SQL Server. The per-
minute rate that is displayed in the gallery entry includes all licensing requirements, including
those for SQL Server.
3. Sign in to the Azure portal with your Azure Pass or Microsoft Account credentials.
5. In the search box, type SQL Server 2017, then click SQL Server 2017.
6. In the results, click SQL Server 2017 Enterprise Windows Server 2016.
7. In the SQL Server 2017 Enterprise Windows Server 2016 blade, in the Select a deployment
model list, click Resource Manager, and then click Create.
8. On the Basics blade, in the Name box, type a name for your server. This must be unique throughout
the whole Azure service, so cannot be specified here. A suggested format is sql2017vm<your
initials><one or more digits>. For example, sql2017vmjs123. Keep a note of the name you have
chosen.
13. Under Resource group, click Use existing and then select resource1.
14. In the Location list, select a location near you, and then click OK.
15. In the Choose a size blade, click View all, click DS11_V2 Standard, and then click Select.
18. On the Summary blade, click Create. Deployment may take some time to complete.
19. When deployment is complete, Azure starts the VM and displays the overview blade. Click Connect,
and then click Open.
21. In the Windows Security dialog box, in the User name box, type demoAdmin, in the Password
box, type Pa55w.rd1234, and then click OK.
23. When the remote desktop session has started, start SQL Server Management Studio and connect to
the local SQL Server instance. Demonstrate the structure of the installation.
24. If the Networks pane appears, click No.
Deploying SQL Server on a Microsoft Azure Virtual Machine 9-5
Lesson 2
Migrating a Database to a Microsoft Azure Virtual
Machine
Contents:
Question and Answers 6
Demonstration: Migrating a Database to an Azure Virtual Machine 6
9-6 Provisioning SQL Databases
Answer: Use the Add Replica Wizard to create a secondary replica of the database on the Azure
virtual machine. When the replication has completed, use failover to change the Azure virtual
machine to be the primary replica of the database, and then remove the on-premises replica. This
is the appropriate method to use when you want to minimize downtime and you have an Always
On deployment.
3. When the script has completed, press any key to close the window.
4. Start SQL Server Management Studio.
5. In the Connect to Server dialog box, select MIA-SQL and click Connect.
6. In Object Explorer, expand Databases, expand ExampleDB, and then expand Tables.
7. Right-click HR.Employees, and then click Select Top 1000 Rows. Show the students the results of
the query against the local database. You will compare results against the cloud-hosted database
after the migration.
8. On the File menu, point to New, and then click Query with current connection.
USE ExampleDB;
GO
BACKUP DATABASE ExampleDB
TO DISK = 'D:\Demofiles\Mod09\ExampleDB.bak'
WITH COMPRESSION, FORMAT,
MEDIANAME = 'MigrationBackups',
NAME = 'Full Backup of ExampleDB';
GO
10. In File Explorer, browse to D:\Demofiles\Mod09, right-click ExampleDB.bak, and then click Copy.
12. Sign in to the Azure portal with your Azure Pass or Microsoft Account credentials.
14. In the list of virtual machines, click the one you created in the first demonstration in this module.
15. On the virtual machine blade, click Connect, and then click Open.
17. In the Windows Security dialog box, click More choices, then click Use a different account.
21. When the remote desktop session has started, open File Explorer, and browse to C:\.
22. On the Home menu, click Paste. Explorer pastes the backup file into the VM.
25. In Object Explorer, expand Databases and show that there are no user databases.
26. On the File menu, point to New, and then click Query with Current Connection.
27. Type the following Transact-SQL script, and then click Execute:
28. When the query completes, in Object Explorer, right-click Databases, and then click Refresh.
31. Close Internet Explorer, close SSMS without saving any changes, then close the Remote Desktop
connection.
9-8 Provisioning SQL Databases
Answer: Place the three virtual machines into a single availability set. This indicates to Azure that
it should automatically place these virtual machines into different fault domains and update
domains.
Deploying SQL Server on a Microsoft Azure Virtual Machine 9-9
Answer: Changes that are made to the on-premises database will not reach the Azure-hosted
database. To avoid this problem, you should perform the migration during off-peak hours and
disable access to the database immediately before you take the backup. After the database has
been restored on the virtual machine, you can reconfigure clients to connect to the SQL Server
instance on the virtual machine and resume normal service.
Managing Databases in the Cloud 10-1
Module 10
Managing Databases in the Cloud
Contents:
Lesson 1: Managing Security in Azure SQL Database 2
Lesson 1
Managing Security in Azure SQL Database
Contents:
Question and Answers 3
Resources 3
Demonstration: Encrypting Sensitive Data 3
Managing Databases in the Cloud 10-3
Resources
Reference Links: Click the Script option, and then select New Query Window to see the
syntax for both Column Master Key and Column Encryption Key. You can also right-click
existing keys, and then select Script … to view the script in a new query window.
Best Practice: You can create Windows PowerShell scripts to create encryption keys. You
can also create Windows PowerShell scripts to encrypt data.
Best Practice: Before you add the current Client IP address to the firewall rules, check that
the correct IP address is displayed.
3. In the Login box, type Student, and in the Password box, type Pa55w.rd, and then click Connect.
3. In Object Explorer, expand Databases, expand AdventureWorksLT, expand Security, and then
expand Always Encrypted Keys.
4. Right-click Column Master Keys and click New Column Master Key.
5. In the New Column Master Key dialog box, in the Name box, type CMK1.
6. In the Key store list, select Windows Certificate Store - Current User.
7. Click Generate Certificate. The certificate appears in the list, and then click OK.
8. In Object Explorer, right-click Column Encryption Keys and click New Column Encryption Key.
9. In the New Column Encryption Key dialog box, in the Name box, type CEK1.
10. In the Column master key list, click CMK1, and then click OK. Click Refresh if CMK1 is not showing.
3. Click Execute to show that all the columns are displayed in plaintext.
4. Under Columns, right-click City, and then click Encrypt Column.
6. On the Column Selection page, select City, and in the Encryption Type column, select
Deterministic, and in the Encryption Key column, select CEK1_Auto1. Note the collation message,
and then click Next.
12. Click Execute to run the query to show the column appears with obfuscated text. NOTE: Values are
repeated because deterministic encryption has been used, and each City appears more than once.
14. Highlight the query and click Execute to show the number of Cities in each postal code. This is
possible because deterministic encryption was selected.
16. The PostalCode column cannot be encrypted while it is included in an index. Run the first part of the
script to drop the index.
17. In Object Explorer, right-click PostalCode, and then click Encrypt Column.
18. In the Always Encrypted wizard, on the Introduction page, click Next.
19. On the Column Selection page, select PostalCode, and in the Encryption Type column, click
Randomized, and in the Encryption Key column, click CEK1_Auto1. Note the collation message,
and then click Next.
21. On the Run Settings page, ensure Proceed to finish now is selected, and then click Next.
26. Click Execute to show that the columns appear with obfuscated text.
27. In the query window, type:
28. Highlight the query and click Execute to show that the GROUP BY operation fails with randomized
encryption. The error message explains that Deterministic encryption is required for the statement to
succeed.
5. On the Run Settings page, ensure Proceed to finish now is selected, and then click Next.
9. Highlight the query and click Execute to show that the PostalCode column has been decrypted.
10. In Object Explorer, right-click SalesLT.Address, point to Script Table as, point to CREATE To, and
then click New Query Editor Window. Point out the encrypted column, and the encryption
algorithm used.
10-6 Provisioning SQL Databases
11. Close SQL Server Management Studio, without saving any changes.
Managing Databases in the Cloud 10-7
Lesson 2
Configuring Azure Storage
Contents:
Question and Answers 8
Demonstration: Creating a Storage Pool 8
10-8 Provisioning SQL Databases
( ) Queue storage
( ) Hierarchical storage
( ) File storage
( ) BLOB storage
Answer:
( ) Queue storage
(√) Hierarchical storage
( ) File storage
( ) BLOB storage
3. In the User Account Control dialog box, click Yes, and wait for the script to finish.
4. Open Internet Explorer and navigate to the Azure portal at www.azure.portal.com. Sign in with
your Azure pass credentials.
7. From the Essentials group, copy the Public IP address onto the clipboard. If prompted, click Allow
Access.
8. Change to the Start screen, type Remote Desktop and then click Remote Desktop Connection.
9. Connect to the Azure VM by pasting the IP address into the Computer box (delete everything after
the IP address), and then click Connect.
10. When prompted, type the password Pa55w.rd, and then click OK.
11. In the Remote Desktop Connection dialog box, click Yes. The Server Manager dashboard is
displayed.
13. In Server Manager, click File and Storage Services, Volumes, and then Storage Pools.
15. Next to Storage Pools, click Tasks, and then click New Storage Pool.
Managing Databases in the Cloud 10-9
16. In the New Storage Pool Wizard dialog box, on the Before you begin page, click Next.
17. On the Specify a storage pool name and subsystem page, in the Name box, type MyStoragePool,
and click Next.
18. On the Select physical disks for the storage pool, select all four disks, and click Next.
21. Click MyStoragePool to see that it is made up of the four disks you selected.
3. On the Start menu, right-click Windows PowerShell ISE, point to More, and then click Run as
administrator.
8. Use Run Selection to run the script under # List the physical disks. Note that the media type is
unspecified.
9. Copy the UniqueID of the disk identified as LUN 1 to the $uniqueIdPremium1 variable value
(between ““).
10. Copy the UniqueID of the disk identified as LUN 2 to the $uniqueIDStandard1 variable value.
11. Copy the UniqueID of the disk identified as LUN 3 to the $uniqueIDStandard2 variable value.
12. Copy the UniqueID of the disk identified as LUN 4 to the $uniqueIDStandard3 variable value.
13. Once all the variables have a value, use Run Selection to run the script under # Initialize variables.
14. Use Run Selection to run the script under # Set media type.
15. To check the media types have been assigned correctly, run the script under # List the physical
disks. You will see that the media types are now set.
2. Next to Virtual Disks, click Tasks, and click New Virtual Disk.
3. In the Select the storage pool dialog box, click MyStoragePool, and then click OK.
4. In the New Virtual Disk Wizard, on the Before you begin page, click Next.
5. On the Specify the virtual disk name, in the Name box, type MyVirtualDisk.
6. Select the Create Storage tiers on this virtual disk check box, and then click Next.
10-10 Provisioning SQL Databases
8. On the Select the storage layout page, click Simple, and then click Next.
9. On the Specify the provisioning type page, click Fixed, and then click Next.
10. On the Specify the size of the virtual disk page, in the Faster Tier box, type 85, and in the Standard
Tier box, type 180, and then click Next.
11. On the Confirm selections page, click Create. The tiered virtual disk will be created.
12. On the View results page, click Close to finish. You can then create a drive letter.
13. In the New Volume Wizard, on the Before you begin page, click Next.
14. On the Select the server and disk page, click MyVirtualDisk, and then click Next.
15. On the Specify the size of the volume page, click Next.
19. On the Completion page, click Close. You can now see the new virtual disk you created.
20. Close Server Manager.
Lesson 3
Azure Automation
Contents:
Question and Answers 12
Demonstration: Introducing Azure Automation 12
10-12 Provisioning SQL Databases
Steps
Select a runbook
Answer:
Steps
3 Select a runbook
7. On the Add Automation Account blade, in the Name box, type automate + your initials. The
name must be in lowercase characters and numbers. A green tick appears when the name is
acceptable. If necessary, add additional numbers to create a unique name.
8. In the Resource group box, either create a new resource group, or select the resource group created
in the first demo.
9. In the Location box, select a Microsoft data center close to you.
11. Click Create. The Automation Account takes a short while to be created. A message is displayed when
the account has been created.
12. Click All resources to see that the new Automation account has been created.
13. Click on the new Automation account name as named in step 7. The Automation Account blade is
displayed.
19. Click the Hello World for Azure Automation runbook (PowerShell Workflow Runbook).
23. On line 33, overtype World with your name, and then click Save.
26. In the Start Runbook blade, click OK, the workflow runs in a test window.
27. Click Output to see the results.
Review Question(s)
Question: What are the main data security concerns in your organization? Which features of Azure SQL
Database are most appropriate to mitigate those concerns?
Email. Partially obfuscate email addresses. This may be used to identify people, without revealing the
full email address.
Credit card. Only the last four digits of a credit card number are displayed; the rest of the number is
masked.