Quickstart: Back up & restore database with SSMS - SQL Server (2024)

  • Article

Applies to: Quickstart: Back up & restore database with SSMS - SQL Server (1) SQL Server

In this quickstart, you create a new database, take a full backup of it, and then restore it.

For a more detailed how-to, see Create a full database backup and Restore a database backup using SSMS.

Prerequisites

To complete this quickstart, you need:

Create a test database

  1. Launch SQL Server Management Studio (SSMS) and connect to your SQL Server instance.

  2. Open a New Query window.

  3. Create your test database using the following Transact-SQL (T-SQL) code.

    USE [master];GOCREATE DATABASE [SQLTestDB];GOUSE [SQLTestDB];GOCREATE TABLE SQLTest ( ID INT NOT NULL PRIMARY KEY, c1 VARCHAR(100) NOT NULL, dt1 DATETIME NOT NULL DEFAULT GETDATE());GOUSE [SQLTestDB];GOINSERT INTO SQLTest (ID, c1) VALUES (1, 'test1');INSERT INTO SQLTest (ID, c1) VALUES (2, 'test2');INSERT INTO SQLTest (ID, c1) VALUES (3, 'test3');INSERT INTO SQLTest (ID, c1) VALUES (4, 'test4');INSERT INTO SQLTest (ID, c1) VALUES (5, 'test5');GOSELECT * FROM SQLTest;GO
  4. Refresh the Databases node in Object Explorer to see your new database.

Take a backup

To take a backup of your database, follow these steps, using SQL Server Management Studio or Transact-SQL:

  • SSMS
  • T-SQL
  1. Launch SQL Server Management Studio (SSMS) and connect to your SQL Server instance.
  2. Expand the Databases node in Object Explorer.
  3. Right-click the database, hover over Tasks, and select Back up....
  4. Under Destination, confirm that the path for your backup is correct. If you need to change the path, select Remove to remove the existing path, and then Add to type in a new path. You can use the ellipses to navigate to a specific file.
  5. Select OK to take a backup of your database.

Quickstart: Back up & restore database with SSMS - SQL Server (2)

To read more about the different backup options, see BACKUP.

Restore a backup

  • SSMS
  • T-SQL

To restore your database, follow these steps:

  1. Launch SQL Server Management Studio (SSMS) and connect to your SQL Server instance.

  2. Right-click the Databases node in Object Explorer and select Restore Database....

    Quickstart: Back up & restore database with SSMS - SQL Server (3)

  3. Select Device:, and then select the ellipses (...) to locate your backup file.

  4. Select Add and navigate to where your .bak file is located. Select the .bak file and then select OK.

  5. Select OK to close the Select backup devices dialog box.

  6. Select OK to restore the backup of your database.

    Quickstart: Back up & restore database with SSMS - SQL Server (4)

Clean up resources

Run the following Transact-SQL command to remove the database you created, along with its backup history in the msdb database:

EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'SQLTestDB'GOUSE [master];GODROP DATABASE [SQLTestDB];GO

Related content

Quickstart: Back up & restore database with SSMS - SQL Server (2024)
Top Articles
Bitcoin Risks and Opportunities | City National Bank
5 Biggest Financial Risks In Retirement | Bankrate
My Arkansas Copa
Urist Mcenforcer
Inducement Small Bribe
Angela Babicz Leak
Restored Republic January 20 2023
Is pickleball Betts' next conquest? 'That's my jam'
FFXIV Immortal Flames Hunting Log Guide
Tv Guide Bay Area No Cable
Professor Qwertyson
Poe Pohx Profile
Sprague Brook Park Camping Reservations
Craigslistdaytona
Nexus Crossword Puzzle Solver
Whitley County Ky Mugshots Busted
Thotsbook Com
Lima Funeral Home Bristol Ri Obituaries
Chastity Brainwash
Water Days For Modesto Ca
Lehmann's Power Equipment
ZURU - XSHOT - Insanity Mad Mega Barrel - Speelgoedblaster - Met 72 pijltjes | bol
Geometry Review Quiz 5 Answer Key
Craigslist Clinton Ar
Katie Sigmond Hot Pics
Aerocareusa Hmebillpay Com
Craigslist Houses For Rent In Milan Tennessee
Del Amo Fashion Center Map
BJ 이름 찾는다 꼭 도와줘라 | 짤방 | 일베저장소
Makemv Splunk
Milwaukee Nickname Crossword Clue
Craigslist Brandon Vt
Summoners War Update Notes
Publix Christmas Dinner 2022
Revelry Room Seattle
Craigslist Sf Garage Sales
11 Pm Pst
Boone County Sheriff 700 Report
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
Toth Boer Goats
How Does The Common App Work? A Guide To The Common App
Danielle Ranslow Obituary
Bob And Jeff's Monticello Fl
Sofia With An F Mugshot
5A Division 1 Playoff Bracket
Love Words Starting with P (With Definition)
Costco The Dalles Or
Tyrone Dave Chappelle Show Gif
Rise Meadville Reviews
Fahrpläne, Preise und Anbieter von Bookaway
Tenichtop
Latest Posts
Article information

Author: Pres. Carey Rath

Last Updated:

Views: 6610

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Pres. Carey Rath

Birthday: 1997-03-06

Address: 14955 Ledner Trail, East Rodrickfort, NE 85127-8369

Phone: +18682428114917

Job: National Technology Representative

Hobby: Sand art, Drama, Web surfing, Cycling, Brazilian jiu-jitsu, Leather crafting, Creative writing

Introduction: My name is Pres. Carey Rath, I am a faithful, funny, vast, joyous, lively, brave, glamorous person who loves writing and wants to share my knowledge and understanding with you.