0% found this document useful (0 votes)
16 views

SQL TipsnHints - Maintenance - Restore Server Database Samples

This document provides instructions for restoring SQL Server sample databases. It explains that sample databases can be downloaded from Blackboard in .bak files and restored. The steps shown are to create a folder for the files, run SQL Server Management Studio, right click to restore a database, select the .bak file, and check that the database is now shown in Object Explorer. Potential issues like authorization errors and preventing changes are also addressed.

Uploaded by

mongome2k
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

SQL TipsnHints - Maintenance - Restore Server Database Samples

This document provides instructions for restoring SQL Server sample databases. It explains that sample databases can be downloaded from Blackboard in .bak files and restored. The steps shown are to create a folder for the files, run SQL Server Management Studio, right click to restore a database, select the .bak file, and check that the database is now shown in Object Explorer. Potential issues like authorization errors and preventing changes are also addressed.

Uploaded by

mongome2k
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

SCHOOL OF COMPUTING, ENGINEERING & DIGITAL TECHNOLOGIES

SQL TIPSNHINTS - RESTORE SERVER DATABASE SAMPLES

SQL TipsnHints - Restore Server Database Samples

You will need to download and restore the SQL Server Samples Databases used in the Demos, Labs
and ICA solutions.

All SQL Server Database Samples are available from Blackboard: Week 0: SQL Server Databases for
Labs & Home

Step 1: Make a Directory [SSMS] and download the SQL Server .bak files from Blackboard - Week 0:
SQL Server Databases for Labs & Home

 TU Labs: drive F or drive U: on the TU Labs


 Home Setup: make a SSMS folder on your hardrive.

Make a folder on your User Drive are either U: or F: drive and copy over the .Zip files from
Blackboard session.

Oct 2022 Samples SQL Server Samples which need Restoring on TU Labs and Home PCs.

 Olympics.bak: 120 years of olympians, events and medals


 Movies.bak: worlds movie library database
 Video_Games: worlds video game library database.
 Superheros: Superhero database
 Universities: worlds Times ranked university .

Oct 2022 Update: The following should be preinstalled in TU Labs.

 TSQL.bak
 MusicMansh.bak
 FleetFactors.bak
 NHS.bak (SQL Server 2019)
 Library.bak

Step 2: Run SQL Server or follow the instructions below if in the TU Labs.

In TU Labs run SQL Server or SSMS from Appsanywhere

Launch the SQL Server Management Studio.

Mansha Nawaz SQL TipsnHints - Restore Server Database Samples Page 1 of 8


SCHOOL OF COMPUTING, ENGINEERING & DIGITAL TECHNOLOGIES

SQL TIPSNHINTS - RESTORE SERVER DATABASE SAMPLES

Step 3: To Restore the .bak files right click the Database for the Restore Database menu option as
seen below:

Step 4: Click on Device and expand the … on the

Step 5: Click Add and browse to where you have downloaded the .bak files to.

Mansha Nawaz SQL TipsnHints - Restore Server Database Samples Page 2 of 8


SCHOOL OF COMPUTING, ENGINEERING & DIGITAL TECHNOLOGIES

SQL TIPSNHINTS - RESTORE SERVER DATABASE SAMPLES

Note: Defaults SSMS location for Backups to restore from is:

C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Backup

However, the .bak files can be loaded from the hardrives folder you have downloaded to and do
note SQL Server will not restore from USB or external drives.

Notice in the example below from TU Labs the .baks where downloaded to [F: \TSQL-Mod00 – SQL
Server DB]

Mansha Nawaz SQL TipsnHints - Restore Server Database Samples Page 3 of 8


SCHOOL OF COMPUTING, ENGINEERING & DIGITAL TECHNOLOGIES

SQL TIPSNHINTS - RESTORE SERVER DATABASE SAMPLES

For the Demo I have selected tuTSQL (it may also be referred to as TSQL in all the Demo and Lab
sessions).

Step 5: Click on OK and SSMS will have restored the TSQL Database used throughout most of the
Demos.

Mansha Nawaz SQL TipsnHints - Restore Server Database Samples Page 4 of 8


SCHOOL OF COMPUTING, ENGINEERING & DIGITAL TECHNOLOGIES

SQL TIPSNHINTS - RESTORE SERVER DATABASE SAMPLES

Mansha Nawaz SQL TipsnHints - Restore Server Database Samples Page 5 of 8


SCHOOL OF COMPUTING, ENGINEERING & DIGITAL TECHNOLOGIES

SQL TIPSNHINTS - RESTORE SERVER DATABASE SAMPLES

Step 6: Make sure the .bak is correctly load and the SQL Server Database is shown correctly in the
Object Explorer as shown below:

Authorisation and Error 15517:


We can Backup and Restore SQL Server Databases – see SQL Server TipsnHints – Backup and
Restore Databases.

However sometimes you will receive the following error as may not be authorised or have
permissions to access the Database.

You will need to assign authorisation for your SQL Server account to access the Database(s)
as follows:

Mansha Nawaz SQL TipsnHints - Restore Server Database Samples Page 6 of 8


SCHOOL OF COMPUTING, ENGINEERING & DIGITAL TECHNOLOGIES

SQL TIPSNHINTS - RESTORE SERVER DATABASE SAMPLES

Simply modify the below author authorisation by changing TSQL to the restored database
name.

-- Microsoft SQL Server, Error:15174 when restoring .bak SQL DBs.


-- Login 'DomainName\abc'-- owns one or more database(s).
-- How to change the owner of da-- Change the owner of database(s)before dropping
the login.

--To check the ownership of database "AdventureWorks2019"


SELECT name as [DB Name],
suser_sname(owner_sid) as [Owner]
FROM sys.databases
WHERE name='AdventureWorks2019'

--Change the ownership of database "AdventureWorks2019" to sa


ALTER AUTHORIZATION ON DATABASE::AdventureWorks2019 TO sa;

--Change the ownership of database "TSQL" to sa


ALTER AUTHORIZATION ON DATABASE::TSQL TO sa;

Saving Changes not permitted Error:


By default SQL Server may also not permit you to make changes to the Database so you may
also need to uncheck the Prevent making changes under Tools – Options as follows:

SQL Server Error: Saving Changes is not permitted


1. Open SQL Server Management Studio.
2. From the file menu, choose Tools à Options.
3. From the left menu, choose Designers.
4. Uncheck the box entitled Prevent saving changes that require table re-
creation.
5. Press OK to save.

Mansha Nawaz SQL TipsnHints - Restore Server Database Samples Page 7 of 8


SCHOOL OF COMPUTING, ENGINEERING & DIGITAL TECHNOLOGIES

SQL TIPSNHINTS - RESTORE SERVER DATABASE SAMPLES

Uncheck – prevent saving


changes

Demo and Lab TSQL Code


The Demo and Lab TSQL Code should work once you have downloaded the appropriate SQL Server
Sample DB to work on. On home machines you may simply double click the .sql demo files.

Note in TU Labs you will have to open .sql files in Notepad and copy over the TSQL Code.

Mansha Nawaz SQL TipsnHints - Restore Server Database Samples Page 8 of 8

You might also like