0% found this document useful (0 votes)
93 views7 pages

Lab Answer Key - Module 3 - Working With Databases and Storage

This document provides instructions for three lab exercises: 1. Configuring tempdb storage by modifying the tempdb database files and locations. 2. Creating new databases called HumanResources and InternetSales with specified file locations and sizes. 3. Attaching an existing AWDataWarehouse database with multiple filegroups, and configuring one filegroup as read-only.

Uploaded by

Alekzanful
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
93 views7 pages

Lab Answer Key - Module 3 - Working With Databases and Storage

This document provides instructions for three lab exercises: 1. Configuring tempdb storage by modifying the tempdb database files and locations. 2. Creating new databases called HumanResources and InternetSales with specified file locations and sizes. 3. Attaching an existing AWDataWarehouse database with multiple filegroups, and configuring one filegroup as read-only.

Uploaded by

Alekzanful
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

Lab Answer Key: Module 3: Working with Databases and Stor

Lab: Managing Database Storage

Exercise 1: Configuring tempdb Storage

Task 1: Prepare the Lab Environment

1. Ensure that the 20462C­MIA­DC and 20462C­MIA­SQL virtual machines 
and then log on to 20462C­MIA­SQL as ADVENTUREWORKS\Student
password Pa$$w0rd.

2. In the D:\Labfiles\Lab03\Starter folder, right­click Setup.cmd, and then 
administrator.

3. Click Yes when prompted to confirm you want to run the command file, 
script to finish.

Task 2: Configure tempdb Files

1. Start SQL Server Management Studio and connect to the MIA­SQL databa
using Windows authentication.

2. In Object Explorer, expand Databases, expand System Databases, right­c
and click Properties.

3. On the Files page, view the current file settings. Then click Cancel.

4. On the toolbar, click New Query.
5. Enter the following statements and click Execute alternatively, you can 
Configure TempDB.sql script file in the D:\Labfiles\Lab03\Solution folder):

USE master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, SIZE = 10MB, FILEGROWTH =
= 'T:\tempdb.mdf');
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, SIZE=5MB, FILEGROWTH = 1MB,
'T:\templog.ldf');
GO

6. In Object Explorer, right­click MIA­SQL and click Restart. When prompted 
changes, to restart the service, and to stop the dependent SQL Server 
Yes.

7. View the contents of T:\ and note that the tempdb.mdf and tempdb.ldf
moved to this location.

8. In SQL Server Management Studio, in Object Explorer, right­click tempdb
Properties.

9. On the Files page, verify that the file settings have been modified. Then 

10. Save the script file as Configure TempDB.sql in the D:\Labfiles\Lab03\Sta

11. Keep SQL Server Management Studio open for the next exercise.

Result: After this exercise, you should have inspected and configured the tempdb database.

Exercise 2: Creating Databases
Task 1: Create the HumanResources Database

1. In SQL Server management Studio, click New Query.

2. Enter the following statements and click Execute alternatively, you can 
HumanResources.sql script file in the D:\Labfiles\Lab03\Solution folder)::

CREATE DATABASE HumanResources


ON PRIMARY
(NAME = 'HumanResources', FILENAME = 'M:\Data\HumanResourc
SIZE = 50MB, FILEGROWTH = 5MB)
LOG ON
(NAME = 'HumanResources_log', FILENAME =
'L:\Logs\HumanResources.ldf', SIZE = 5MB, FILEGROWTH =
GO

3. On Object Explorer, right­click the Databases folder and click Refresh 
HumanResources database has been created.

4. Save the script file as Create HumanResources.sql in the D:\Labfiles\Lab
folder.

Task 2: Create the InternetSales Database

1. In SQL Server management Studio, click New Query.

2. Enter the following statements and click Execute (alternatively, you can 
InternetSales.sql script file in the D:\Labfiles\Lab03\Solution folder):
CREATE DATABASE InternetSales
ON PRIMARY
(NAME = 'InternetSales', FILENAME = 'M:\Data\InternetSales
= 5MB, FILEGROWTH = 1MB),
FILEGROUP SalesData
(NAME = 'InternetSales_data1', FILENAME =
'M:\Data\InternetSales_data1.ndf', SIZE = 100MB, FILEGROWT
(NAME = 'InternetSales_data2', FILENAME =
'N:\Data\InternetSales_data2.ndf', SIZE = 100MB, FILEGROWT
LOG ON
(NAME = 'InternetSales_log', FILENAME = 'L:\Logs\InternetS
SIZE = 2MB, FILEGROWTH = 10%);
GO

3. Under the existing code, enter the following statements. Then select the 
have just added, and click Execute.

ALTER DATABASE InternetSales


MODIFY FILEGROUP SalesData DEFAULT;
GO

4. On Object Explorer, right­click the Databases folder and click Refresh 
InternetSales database has been created.

5. Save the script file as Create InternetSales.sql in the D:\Labfiles\Lab03\St

Task 3: View Data File Information
1. In SQL Server Management Studio, open the ViewFileInfo.sql script file 
D:\Labfiles\Lab03\Starter folder.

2. Select the code under the comment View page usage and click Execute
retrieves data about the files in the InternetSales database.

3. Note the UsedPages and TotalPages values for the SalesData filegroup.

4. Select the code under the comment Create a table on the SalesData fileg
Execute.

5. Select the code under the comment Insert 10,000 rows and click Execute

6. Select the code under the comment View page usage again and click 

7. Note the UsedPages value for the SalesData filegroup, and verify that 
table is spread across the files in the filegroup.

Result: After this exercise, you should have created a new HumanResources database and 
database that includes multiple filegroups.

Exercise 3: Attaching a Database

Task 1: Attach the AWDataWarehouse Database

1. Move AWDataWarehouse.ldf from the D:\Labfiles\Lab03\Starter\ folder 
folder.

2. Move the following files from the D:\Labfiles\Lab03\Starter\ folder to the 

o AWDataWarehouse.mdf
o AWDataWarehouse_archive.ndf
o AWDataWarehouse_current.ndf

3. In SQL Server Management Studio, in Object Explorer, right­click Database
Attach.

4. In the Attach Databases dialog box, click Add. Then in the Locate Databa
box, select the M:\Data\AWDataWarehouse.mdf database file and click 

5. In the Attach Databases dialog box, after you have added the master 
that all of the database files are listed. Then click OK.

6. In Object Explorer, under Databases, verify that AWDataWarehouse is 

Task 2: Configure Filegroups

1. In Object Explorer, right­click the AWDataWarehouse database and click 

2. On the Filegroups page, view the filegroups used by the database.

3. Select the Read­Only checkbox for the Archive filegroup and click OK

4. In Object Explorer, expand AWDataWarehouse, and expand Tables. Then
dbo.FactInternetSales table and click Properties.

5. On the Storage page, verify that the dbo.FactInternetSales table is stored
filegroup. Then click Cancel.

6. Right­click the dbo.FactInternetSalesArchive table and click Properties

7. On the Storage page, verify that the dbo.FactInternetSalesArchive table 
Archive filegroup. Then click Cancel.

8. In Object Explorer, right­click the dbo.FactInternetSales table and click 
Rows.
9. Change the SalesAmount value for the first record to 2500 and press Ente
record. Then close the dbo.FactInternetSales table.

10. In Object Explorer, right­click the dbo.FactInternetSalesArchive table 
200 Rows.

11. Change the SalesAmount value for the first record to 3500 and press Ente
record.

12. View the error message that is displayed and click OK. Then press Esc
update and close the dbo.FactInternetSalesArchive table.

Result: After this exercise, you should have attached the AWDataWarehouse database to MIA­S

You might also like