Skip to content

Latest commit

 

History

History
88 lines (58 loc) · 3.5 KB

File metadata and controls

88 lines (58 loc) · 3.5 KB
title Delete a Database
description Learn how to delete a user-defined database in SQL Server Management Studio in SQL Server by using SQL Server Management Studio or Transact-SQL.
author WilliamDAssafMSFT
ms.author wiassaf
ms.reviewer randolphwest
ms.date 01/26/2026
ms.service sql
ms.subservice supportability
ms.topic how-to
helpviewer_keywords
database removal [SQL Server], SQL Server Management Studio
removing databases
deleting databases
dropping databases
databases [SQL Server], dropping
database removal [SQL Server]
monikerRange =azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current

Delete a database

[!INCLUDE SQL Server Azure SQL Database Azure SQL Managed Instance]

This article describes how to delete a user-defined database in [!INCLUDE ssnoversion] by using [!INCLUDE ssManStudioFull] or [!INCLUDE tsql].

Prerequisites

  • Delete any database snapshots that exist on the database. For more information, see Drop a Database Snapshot.

  • If the database is involved in log shipping, remove log shipping.

  • If the database is published for transactional replication, or published or subscribed to merge replication, remove replication from the database.

Warning

Consider taking a full backup of the database before dropping it. You can recreate a deleted database only by restoring a full backup. For more information, see Quickstart: Backup and restore a SQL Server database with SSMS.

Permissions

To run DROP DATABASE, you need CONTROL permission on the database.

Use SQL Server Management Studio

  1. In Object Explorer, connect to an instance of the [!INCLUDE ssDEnoversion], and then expand that instance.

  2. Expand Databases, right-click the database to delete, and then select Delete.

  3. Confirm the correct database is selected, and then select OK.

Use Transact-SQL

For more information, see DROP DATABASE.

  1. Connect to the [!INCLUDE ssDE].

  2. From the Standard bar, select New Query.

  3. Copy and paste the following example into the query window and select Execute. This example removes the Sales and NewSales databases.

USE master;
GO
DROP DATABASE Sales, NewSales;

Follow up: After deleting a database

Back up the master database. If you need to restore master, any database that you deleted since the last backup of master still has references in the system catalog views and might cause error messages.

Limitations

You can't delete system databases. For more information, see DROP DATABASE.

Related content