You are on page 1of 58

7/23/2019 Print content

Administering Microsoft SQL Server 2012 Databases

Implement a Migration Strategy

Introduction
Restore vs. Detach / Attach
Upgrade from a Previous Version
Summary

Introduction
The Implement a Migration Strategy module provides you with the instruction and
server hardware to develop your hands on skills in the defined topics. This module
includes the following exercises:

Restore vs. Detach / Attach


Upgrade from a Previous Version

This lab now includes a SQL 2014 device, this means you can now carry out the
steps in SQL 2012 and SQL 2014. Notes have been included where any differences
in the steps may occur.

Lab time: It will take approximately 1 hour to complete this lab.

Lab Diagram

During your session you will have access to the following lab configuration.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 1/58
7/23/2019 Print content

Connecting to your lab

During your session you will have access to the following lab configuration. Depending
on the exercises you may or may not use all of the devices, but they are shown here in the
layout to get an overall understanding of the topology of the lab.

PLABSQL01 (Windows Server 2008 R2 - Domain Controller, SQL Server 1)


PLABSQL02 (Windows Server 2008 R2 - Domain Server, SQL Server 2)

For SQL 2014 you will use the following device:

PLABSQL03 (SQL Server 3)

To start, simply choose a device and click Power on. In some cases, the devices may
power on automatically.

For further information and technical support, please see our Help and Support
page.

Copyright Notice
This document and its content is copyright of Practice-IT - © Practice-IT 2014. All rights reserved. Any
redistribution or reproduction of part or all of the contents in any form is prohibited other than the
following:
1) You may print or download to a local hard disk extracts for your personal and non-commercial use
only.
2) You may copy the content to individual third parties for their personal use, but only if you
acknowledge the website as the source of the material. You may not, except with our express written

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 2/58
7/23/2019 Print content

permission, distribute or commercially exploit the content. Nor may you transmit it or store it in any
other website or other form of electronic retrieval system.

Exercise 1 - Restore vs. Detach / Attach


In this exercise, you will perform the tasks required to implement a migration strategy.

To get a better understanding of this technology, please refer to your course material or
use your preferred search engine to research this topic in more detail.

Task 1 - Detach a database

To restore a database you need to first back up the database. Without the backup, the
database cannot be restored. Backing up a database is not the same as detaching and
attaching a database. Detaching a database is a simple operation in which the database is
no longer attached to a SQL Server. Attaching brings the database online in the SQL
Server.

To restore a database, you need to perform the following steps:

Back up the database using SQL Server Management Studio. Alternatively, you can
use SQL statements.
Copy the backed up database to the destination server.
Restore the backed up database on the destination server.

To learn how to restore a database, we will first have to attach the database and then back
it up, and then we can restore it. Therefore, let’s first attach a database named
AdventureWorks2012.

SQL 2014 Note: To complete the following steps in SQL 2014, you will need to
replace the AdventureWorks2012 database name with AdventureWorks2014
in all the instances in text as well as code.

Note: If this database is already attached, ensure that you detach the database
first.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 3/58
7/23/2019 Print content

Step 1
Ensure you have powered on the required devices indicated in the Introduction of this
lab.

Connect to PLABSQL02 device.

Double-click SQL Server Management Studio on the desktop.

Step 2
In the Connect to Server dialog box, verify that the Server name text box indicates
PLABSQL02.

Click Connect.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 4/58
7/23/2019 Print content

Step 3
After the connection is successful, the PLABSQL02 server is displayed in Object
Explorer.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 5/58
7/23/2019 Print content

Step 4
You can detach the database. To do this, expand Databases and right-click
AdventureWorks2012, select Tasks, and then select Detach.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 6/58
7/23/2019 Print content

Step 5
The Detach Database dialog box is displayed.

On the Databases to detach section, select Drop Connections and Update


Statistics and click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 7/58
7/23/2019 Print content

Step 6
In the Object Explorer, click the Refresh button in the menu.

Note that AdventureWorks2012 is no longer listed under the Databases node, after
detaching it.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 8/58
7/23/2019 Print content

Keep all devices powered on in their current state and proceed to the next task.

Task 2 - Attach a database

To attach a database to PLABSQL02 server, perform the following steps:

Step 1
On PLABSQL02 server, ensure that you have SQL Server Management Studio
open.

Right-click Databases node and select Attach.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 9/58
7/23/2019 Print content

Step 2
The Attach Databases dialog box is displayed.

Click Add.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 10/58
7/23/2019 Print content

Step 3
On the Locate Database Files - PLABSQL02 dialog box, you are automatically
redirected to:

C:\Program Files\Microsoft SQL


Server\MSSQL11.MSSQLSERVER\MSSQL\DATA

Select AdventureWorks2012_Data.mdf from the list and click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 11/58
7/23/2019 Print content

Step 4
Back in the Attach Databases dialog box, notice that the selected database is now
added in the Attach Databases dialog box.

Click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 12/58
7/23/2019 Print content

Step 5
Find the AdventureWorks2012 database is now added to the Databases node.

Note: You may have to refresh your view, you can do this by selecting database
and click the refresh button located in the top tab, or by pressing F5)

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 13/58
7/23/2019 Print content

Keep all devices powered on in their current state and proceed to the next task.

Task 3 - Back up a database

SQL 2014 Note: To complete the following steps in SQL 2014, you will need to
replace the AdventureWorks2012 database name with AdventureWorks2014
in all the instances in text as well as code.

To perform a backup of the AdventureWorks2012 database, perform the following steps:

Step 1
On PLABSQL02 server, while SQL Management Studio is open, under the
Databases node, right-click AdventureWorks2012, select Tasks, and then select
Back Up.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 14/58
7/23/2019 Print content

Step 2
On the Back Up Database - AdventureWorks2012 dialog box, keep the default
configuration and click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 15/58
7/23/2019 Print content

Step 3
After the backup is successful, Microsoft SQL Server Management Studio dialog
box displays the completion message.

Click OK to close the dialog box.

Note: Please note the backup of the database finished soon enough because
AdventureWorks2012 is a small database.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 16/58
7/23/2019 Print content

Step 4
You are redirected back to SQL Server Management Studio window.

Keep this application open for the next exercise.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 17/58
7/23/2019 Print content

Keep all devices powered on in their current state and proceed to the next task.

Task 4 - Restore a database

You can now restore the database. For this exercise, you will restore the database on the
same server. However, in a real-life scenario, you will typically perform the restore on a
different server or a different instance of SQL Server.

SQL 2014 Note: To complete the following steps in SQL 2014, you will need to
replace the AdventureWorks2012 database name with AdventureWorks2014
in all the instances in text as well as code.

To restore the AdventureWorks2012 database, perform the following steps:

Step 1

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 18/58
7/23/2019 Print content

On PLABSQL02 server, while SQL Server Management Studio is open, in the left pane,
right-click Databases and then select Restore Database.

Step 2
On the Restore Database dialog box, locate the Source section, select Database
option and then on the drop-down list, select AdventureWorks2012.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 19/58
7/23/2019 Print content

Step 3
Keep the default specifications and click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 20/58
7/23/2019 Print content

Step 4
After the database is successfully restored, you will be prompted with the Microsoft
SQL Server Management Studio dialog box.

Click OK to close the dialog box.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 21/58
7/23/2019 Print content

Step 5
Keep Microsoft SQL Server Management Studio open.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 22/58
7/23/2019 Print content

Keep all devices powered on in their current state and proceed to the next task.

Task 5 - Migrate Security

Users use SQL logins to connect to a Database Engine instance. The database users map
to the logins. When you migrate a database, you must also migrate the logins, which
essentially means migrating the security for the database.

To migrate security, perform the following steps:

Step 1
On PLABSQL02 while in SQL Server Management Studio, expand Security node
click Logins.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 23/58
7/23/2019 Print content

Step 2
Right-click PRACTICELABS\administrator then select Script Login as, select
CREATE TO, and then select New Query Editor Window.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 24/58
7/23/2019 Print content

Step 3
On the middle pane, a new tab called SQLQuery1.sql - PLAB opens.

The login details are now captured in the form of a query.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 25/58
7/23/2019 Print content

Step 4
To save the generated script, right-click on SQLQuery1.sql - PLAB and select Save
SQLQuery1.sql

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 26/58
7/23/2019 Print content

Step 5
On the Save File as dialog box, accept the indicated file name and click Save.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 27/58
7/23/2019 Print content

Step 6
Close SQL Server Management Studio application window.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 28/58
7/23/2019 Print content

Keep all devices powered on in their current state and proceed to the next task.

Task 6 - Test Connectivity

After SQL Server 2012 is installed, you must verify that it is possible for remote clients to
interact with the server. The simplest way of doing this is to attempt a connection by
using the SQL Server 2012 client tools.

Note: You will use PLABSQL01 as the client to connect to the PLABSQL02.

To test connectivity, perform the following steps:

Step 1
Connect to PLABSQL01 and double-click SQL Server Management Studio on the
desktop.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 29/58
7/23/2019 Print content

Step 2
On the Connect to Server dialog box, enter PLABSQL02 in the Server name text
box and click Connect.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 30/58
7/23/2019 Print content

Step 3
After the connection is successful, the PLABSQL02 server is displayed in Object
Explorer.

Close SQL Server Management Studio window.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 31/58
7/23/2019 Print content

Leave the devices you have powered on in their current state and proceed to the next
exercise.

Please note, you will be switching labs so your changes you had made on this exercise will
not be saved.

Exercise 2 - Upgrade from a Previous Version


If you are running SQL Server 2008, you can migrate to Microsoft SQL Server 2012.
Depending upon the version you have, you will need to appropriate choose and upgrade
to the correct version.

To get a better understanding of this technology, please refer to your course material or
use your preferred search engine to research this topic in more detail.

Task 1 - Upgrade SQL Server 2008 to SQL Server 2012


https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 32/58
7/23/2019 Print content

To upgrade from a previous version, which is Microsoft SQL Server 2008, perform the
following steps:

Step 1
Ensure you have powered on the required devices and connect to PLABSQL01.

Click Windows Explorer icon on taskbar.

Step 2
On Windows Explorer, expand Computer and then click DVD Drive (E:).

The content of DVD Drive E are now displayed in the details pane.

Double-click setup to initiate the installation.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 33/58
7/23/2019 Print content

Step 3
The SQL Server 2012 dialog box will appear for a short while and then it will
automatically close.

The SQL Server Installation Center window is now displayed.

In the left pane, click Installation.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 34/58
7/23/2019 Print content

Step 4
On the details pane of the Installation section, in the right pane, click Upgrade from
SQL Server 2005, SQL Server 2008 or SQL Server 2008 R2 web link.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 35/58
7/23/2019 Print content

Step 5
On the SQL Server 2012 Setup wizard - Setup Support Rules page, click OK.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 36/58
7/23/2019 Print content

Step 6
The SQL Server 2012 dialog box appears for a few moments.

On the SQL Server 2012 Setup wizard Product Key page, note that the product key
is automatically entered.

Click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 37/58
7/23/2019 Print content

Step 7
On the License Terms page, select I accept the license terms check box.

Click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 38/58
7/23/2019 Print content

Step 8
On the Product Updates page, please note that you will not be updating this SQL
Server installation.

Therefore, clear Include SQL Server product updates check box.

Note: You can ignore errors about being unable to reach Windows Update
service, if they appear on screen.

Click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 39/58
7/23/2019 Print content

Step 9
Please wait while the Install Setup Files is processing.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 40/58
7/23/2019 Print content

Step 10
On the Setup Support Rules page, it indicates the status of different rules that were
checked on PLABDC01.

You can ignore the warning about this server being a domain controller.

Click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 41/58
7/23/2019 Print content

Step 11
On the Select Instance screen is page, since there is only one instance of the previous
version, it is selected by default.

Click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 42/58
7/23/2019 Print content

Step 12
On the Select Features page, notice that all features are selected.

Click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 43/58
7/23/2019 Print content

Step 13
On the Instance Configuration page, keep the default specifications and click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 44/58
7/23/2019 Print content

Step 14
On the Disk Space Requirements page, it indicates the folder paths where files will be
saved by the SQL setup.

This computer has enough disk space for this SQL Server installation, therefore click
Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 45/58
7/23/2019 Print content

Step 15
On the Server Configuration screen, keep the default configuration and click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 46/58
7/23/2019 Print content

Step 16
On the Full-text Upgrade screen, Import option is selected by default.

Keep the default selection and click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 47/58
7/23/2019 Print content

Step 17
On the Error Reporting page, click Next.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 48/58
7/23/2019 Print content

Step 18
On the Upgrade Rules screen, click Next if no errors are reported.

Note: You must have installed Visual Studio 2010 Service Pack 1 and SQL
Server R2 Service Pack 1 or later for the upgrade to be successful. If you have
not done this, the Upgrade Rules will fail. You will need to halt the upgrade at this
point and complete the installation of both prerequisite.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 49/58
7/23/2019 Print content

Step 19
On the Ready to Upgrade page, read through the summary about this pending
installation.

Click Upgrade.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 50/58
7/23/2019 Print content

Step 20
Please wait while Upgrade Progress is in progress.

Note: The upgrade may take a while to complete.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 51/58
7/23/2019 Print content

Step 21
Click Close when the upgrade process is successfully completed.

Note: A Computer restart may be required if so, click OK. The SQL Server
2012 dialog box is displayed. It will automatically close after a few minutes.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 52/58
7/23/2019 Print content

Step 22
Close SQL Server Installation Center and Windows Explorer windows.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 53/58
7/23/2019 Print content

Step 23
Click Start and in Search programs and files box, type:

Shutdown /r /t 0

Press Enter.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 54/58
7/23/2019 Print content

Keep all devices powered on in their current state and proceed to the next task.

Task 2 - Verify SQL Server upgrade

After upgrading SQL Server 2008 to version 2012, you can verify the upgrade by
performing the following steps:

Step 1
Connect to PLABSQL01 server after 2 minutes to let the server complete its restart.

Launch SQL Server Management Studio from desktop.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 55/58
7/23/2019 Print content

Step 2
On the Connect to Server dialog box, click Connect.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 56/58
7/23/2019 Print content

Step 3
On SQL Server Management Studio window, notice that the plabsql01 in the left
pane is now marked as SQL Server 11.0.2100, which is the SQL Server 2012
version.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 57/58
7/23/2019 Print content

Shut down all virtual machines used in this exercise using Practice Labs power button
function to revert these devices to their default settings.

Alternatively, you may sign out of the lab portal to power down all devices.

Summary
In this module, you covered carried the following practical tasks:

Restoring vs. detaching/attaching a database.


Migrating security.
Upgrade from a previous version.

https://www.practice-labs.com/authenticated/vNext/vn-print-content.aspx 58/58

You might also like