Tutorial: Import-Export-Backup Of MSSQL Database With Microsoft SQL Server Manager Express
Dr. Thomas E. Hicks
Computer Science Department
Trinity University
The purpose of this tutorial is to show how to use Microsoft SQL Server Management Studio Express to (1) import and export data to the same instance of the Microsoft SQL Server Express server. The last section of this tutorial shows how to attach original database data to alternate servers.
If You Have Difficulty With This Tutorial, You Might Find These Help
Prepare You For This Tutorial
I Recommend That My Students Complete The Tutorials In This Order!
Tutorial: Microsft SQL Server Express- 2008 Advanced (With Server Management Studio) Express Install
Tutorial: MSSQL Database Construction With Server Management Studio
There are a number of reasons that you should back up your databases; three of the more important reasons would be:
There are a number of reasons that you should back up your databases; three of the more important reasons would be:
1] We shall backup the Northwind database on Net1. Note that the Northwind database contains 8 tables.

2] The Customers database table contains 91 records. We shall open up our
copy and make sure that the Customers table looks similar to that below.

1] Using the mouse, right-mouse-click on the Northwind Database --> Select Tasks --> Select Back Up... (See Below!)

2] We are going to do a Full Backup. You can rename the backup, but we
are going to leave ours as Northwind-Full Database Backup. This is going
to create a file, called Northwind.bak in directory. Using the mouse,
select/push the OK button. (See Below!)
3] The BackUp takes only seconds to complete. Using the mouse, select/push the OK button. (See Below!)

4] Take a look in directory C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup - you will see file Northwind.bak. (See Below!)

1] Using the mouse, right-mouse-click on the Northwind Database --> Select Delete (See Below!)

2] Using the mouse, select/push the OK button.
3] Note that the Northwind database is no longer there. (See Below!)

1] Suppose we have a copy of our Northwind.bak in directory C:\ (See Below!)

|
IMPORTING PROBLEMS?
I have found that students are sometimes successful importing from drive C
and sometimes not. It depends upon the permissions associated with the drive C
of the computer. They will always have problems importing from the desktop.
In order to consider the permissions we might need, it is best to examine the
default folder that MSSQL uses to backup files.
The required permission for the import is SQLServer2005MSSQLUser
Below, I have shown the default permissions on folder C:\Program
Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup
What To Do If I Have Problems Importing:
Or |
2] Using the mouse, right-mouse-click on Databases --> Select Restore Database (See Below!)

3] Name the database Northwind. Select the From Device radio button. Select the
to identify the backup file. (See Below!)

4] We need to Add the backup file. Using the mouse, select/push the Add
button. (See Below!)

5] Locate the backup file in the top window. Using the mouse, select/push the
OK button. I have selected Northwind.bak on C:\
(See Below!)

6] Using the mouse, select/push the OK button. (See Below!)

7] Check the box beside Northwind-Full Database Backup. Using the mouse,
select/push the OK button. (See Below!)

8] Using the mouse, select/push the OK button. (See Below!)

9] As you can see below, once again we have a Northwind database whose Customer
table has 91 records. This process can be used to make a copies of the Northwind
database on other SQL/SQLEXPRESS Servers. (See Below!)

1] Suppose we have a copy of our Northwind.bak in directory C:\ (See Below!)

2] Using the mouse, right-mouse-click on Databases --> Select Restore Database (See Below!)

3] Name the database Northwind2. Select the From Device radio button. Select the
to identify the backup file. (See
Below!)

4] We need to Add the backup file. Using the mouse, select/push the Add
button. (See Below!)

5] Locate the backup file in the top window. Using the mouse, select/push the
OK button. I have selected Northwind.bak on C:\
(See Below!)

6] Using the mouse, select/push the OK button. (See Below!)

7] Check the box beside Northwind-Full Database Backup. Using the mouse,
select/push the OK button. (See Below!)

8] Using the mouse, select/push the OK button. (See Below!)

9] As you can see below, once again we have a Northwind2 database whose
Customer table has 91 records. This process can be used to make a
duplicate copy of the Northwind database on the same SQL/SQLEXPRESS Server. This
copy might be used to test procedures and queries; it can also be used for
development. (See Below!)

1] Note that I have deleted the OrderDetail and the Orders tables from the Northwind database. I have also reduced the 91 Customer table records to only 12. (See Below!)

1] Suppose we have a copy of our Northwind.bak in directory C:\ (See Below!)

2] Using the mouse, right-mouse-click on Databases --> Select Restore Database (See Below!)

3] Name the database Northwind. Select the From Device radio button. Select the
to identify the backup file. (See
Below!)

4] We need to Add the backup file. Using the mouse, select/push the Add
button. (See Below!)

5] Locate the backup file in the top window. Using the mouse, select/push the
OK button. I have selected Northwind.bak on C:\
(See Below!)

6] Using the mouse, select/push the OK button. (See Below!)

7] Check the box beside Northwind-Full Database Backup. Using the mouse,
select/push the OK button. (See Below!)

8] Using the mouse, select/push the OK button. (See Below!)

9] As you can see below, once again we have a Northwind database whose Customer
table has 91 records. Tables Order Details and Orders have also been restored.
This process can be used to databases on other SQL/SQLEXPRESS Servers.
(See Below!)

1] The techniques above work to backup and restore data from the same database instance. By using attach, we can get the data into other database instances.
2] You might want to download the two files below and copy them into your SQL Server data directory (see below!)

3] Open MSSQL Server Management Studio Express. Right mouse click on Databases and select Attach. (see below!)

4] Push/Select the Add button. (see below!)

5] Select the LibraryApp.mdf in your SQL Server data directory. (see below!)

6] Open MSSQL Server Management Studio Express. Right mouse click on Databases and select Attach. (see below!)

Tutorial: Visual Studio 2008 Install
Tutorial: Visual Studio 2008 SP1 Install
Tutorial: Visual Studio Windows Application - Forms - Basic Forms
Tutorial: Visual Studio Windows Application - Forms - Labels & TextBoxes
Tutorial: Visual Studio Windows Application - Forms - Buttons & Color Picker
Tutorial: Visual Studio Windows Application - Forms - Menu Driven Application With Multiple Forms
Tutorial : Visual Studio Windows Application - Forms - MenuStrip Driven Application
Tutorial: Visual Studio Windows Application - Forms - Passing-Data Between Parent Child Forms
Tutorial: Visual Studio Windows Application - Adding A Web Browser Component To A Database Form
Tutorial: Microsft SQL Server Express- 2008 Advanced (With Server Management Studio) Express Install
Tutorial: MSSQL Database Construction With Server Management Studio
Tutorial: MSSQL Database Import, Export, & Backup With Server-Management-Studio
Tutorial: Visual Studio Windows Application - Forms - MSSQL Connections & ComboBoxes
Tutorial: Visual Studio Windows Application - Forms - MSSQL GUI Connections & DataGrids
Tutorial: Visual Studio Windows Application - Forms -
Custom MSSQL Record Lock-Out System For Multi-User LibraryApp - 1
[Database Configuration, Database Authentication, Generic Database Utilities,
Etc.]
Tutorial: Visual Studio Windows Application - Forms -
Custom MSSQL Record Lock-Out System For Multi-User LibraryApp - 2
[Query Set Views & Navigation Buttons & Filters & Order By]
Tutorial: Visual Studio Windows Application - Forms -
Custom MSSQL Record Lock-Out System For Multi-User LibraryApp - 3
[Login, RecoordLock DB, Authentication, Configure Dynamic Data Combo, Password Fields, CheckBoxes, & Tab Control]
Tutorial: Visual Studio Windows Application - Forms -
Custom MSSQL Record Lock-Out System For Multi-User LibraryApp - 4
[Edit Mode, Normal Mode, Record-Lock Database, Record-Lockout Timing,
Insert Lock Request, Complete Lock Request]
Tutorial: Visual Studio Windows Application - Forms -
Custom MSSQL Record Lock-Out System For Multi-User LibraryApp - 5
[Phase In Record Lock-Out System]