0% found this document useful (0 votes)
23 views3 pages

Document 17

This lab guide provides instructions for installing the AdventureWorks 2022 Database in SQL Server, including prerequisites such as SQL Server 2022 and SSMS version 19.0 or later. It outlines steps for downloading the backup file, preparing the backup location, restoring the database using either SSMS GUI or T-SQL, and verifying the installation. Troubleshooting tips for common errors are also included to assist users during the installation process.

Uploaded by

Dima Azzam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views3 pages

Document 17

This lab guide provides instructions for installing the AdventureWorks 2022 Database in SQL Server, including prerequisites such as SQL Server 2022 and SSMS version 19.0 or later. It outlines steps for downloading the backup file, preparing the backup location, restoring the database using either SSMS GUI or T-SQL, and verifying the installation. Troubleshooting tips for common errors are also included to assist users during the installation process.

Uploaded by

Dima Azzam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ULFG III SEM III Probabilities

Lab Guide : Installing the AdventureWorks 2022 Database in SQL


Server
Prerequisites
• SQL Server 2022 : Ensure that SQL Server 2022 is installed on your machine or a server you can access.
• SQL Server Management Studio (SSMS) : Use version 19.0 or later (recommended for SQL Server
2022).
• Administrator Privileges : You need administrative rights on your SQL Server instance to perform
database restoration.
• Disk Space : At least 1 GB of free disk space is required for the database files.
• Internet Connection : Required to download the backup file from the GitHub repository.

Important Note

Before beginning, ensure you know :


Copyrighted content Dr M AOUDE

• Your SQL Server instance name (e.g., MSSQLSERVER for the default instance).
• Your authentication method (Windows Authentication or SQL Server Authentication).
• The location of your SQL Server backup and data directories (default locations are provided in
Step 2).

Step 1 : Download the AdventureWorks Backup File


1. Navigate to the GitHub release page : AdventureWorks.
2. Under Download backup files, locate the appropriate version :
• For OLTP workloads : AdventureWorks2022.bak (recommended for most users).
• For Data Warehouse : AdventureWorksDW2022.bak.
• For lightweight version : AdventureWorksLT2022.bak.
3. Save the file to a temporary location on your machine (e.g., C:Temp).

Step 2 : Prepare the Backup Location


1. Locate your SQL Server backup directory :
Default instance path:
C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Backup

Named instance path:


C:\Program Files\Microsoft SQL Server\MSSQL16.[INSTANCENAME]\MSSQL\Backup

2. To find your backup directory programmatically using T-SQL :


EXECUTE master.dbo.xp_instance_regread
N’HKEY_LOCAL_MACHINE’,
N’Software\Microsoft\MSSQLServer\MSSQLServer’,
N’BackupDirectory’

3. Copy the downloaded .bak file to this location.


4. Verify permissions :
• Right-click the .bak file → Properties → Security tab.
• Ensure the SQL Server service account has Read access to the file.

Dr Mohamad AOUDE 1
ULFG III SEM III Probabilities

Step 3 : Restore the Database


Method 1 : Using SSMS GUI (Recommended for Beginners)
1. Open SSMS and connect to your SQL Server instance.
2. In Object Explorer :
• Right-click Databases.
• Select "Restore Database...".
• Choose "Device" under Source.
• Click "..." (browse).
• Click "Add".
• Navigate to and select your .bak file.
• Click "OK" twice to return to the Restore Database dialog.
3. Before clicking OK to restore :
• Check the "Files" tab.
• Verify the paths for data (.mdf) and log (.ldf) files.
Copyrighted content Dr M AOUDE

• Ensure sufficient disk space exists in the specified directories.


4. Click "OK" to begin restoration.

Warning

The restore process might take several minutes. Do not close SSMS during this time.

Method 2 : Using T-SQL


-- First, check the backup file contents
RESTORE FILELISTONLY
FROM DISK = ’C:\...\AdventureWorks2022.bak’;

-- Then restore the database


RESTORE DATABASE AdventureWorks2022
FROM DISK = ’C:\...\AdventureWorks2022.bak’
WITH
MOVE ’AdventureWorks2022_Data’ TO
’C:\...\AdventureWorks2022.mdf’,
MOVE ’AdventureWorks2022_Log’ TO
’C:\...\AdventureWorks2022.ldf’,
STATS = 10;

Step 4 : Verify the Installation


1. Run these verification queries :

-- Check database status


SELECT name, state_desc
FROM sys.databases
WHERE name = ’AdventureWorks2022’;

-- Test a simple query


USE AdventureWorks2022;
SELECT TOP 10 * FROM Person.Person;

Dr Mohamad AOUDE 2
ULFG III SEM III Probabilities

-- Check database size and files


USE AdventureWorks2022;
EXEC sp_spaceused;

Troubleshooting
Common Issues and Solutions
• Error 5120 : Cannot open backup file
• Check file permissions.
• Verify SQL Server service account access.
• Try moving the .bak file to a different location.
• Error 3154 : The backup file is corrupt
• Re-download the .bak file.
• Verify the download completed successfully.
Copyrighted content Dr M AOUDE

• Error 1834 : Insufficient disk space


• Check available space in the data directory.
• Consider moving files to a different drive.

Additional Resources
• Official Microsoft Documentation
• SQL Server Samples GitHub Repository
• Download SSMS

Dr Mohamad AOUDE 3

You might also like