Skip to content

Latest commit

 

History

History
95 lines (62 loc) · 4.32 KB

delete-a-database.md

File metadata and controls

95 lines (62 loc) · 4.32 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords monikerRange
Delete a Database
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.
WilliamDAssafMSFT
wiassaf
05/24/2023
sql
supportability
conceptual
database removal [SQL Server], SQL Server Management Studio
removing databases
deleting databases
dropping databases
databases [SQL Server], dropping
database removal [SQL Server]
=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 [!INCLUDEssnoversion] by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql].

Prerequisites

  • Delete any database snapshots that exist on the database. For more information, see Drop a Database Snapshot (Transact-SQL).

  • 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. A deleted database can be re-created only by restoring a full backup. For more information, see Quickstart: Backup and restore a SQL Server database on-premises.

Security

Permissions

To execute DROP DATABASE, at a minimum, a user must have CONTROL permission on the database.

Using Azure Data Studio (preview)

To delete a database

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

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

  3. To confirm you want to delete the database, select Yes.

Using SQL Server Management Studio

To delete a database

  1. In Object Explorer, connect to an instance of the [!INCLUDEssDEnoversion], 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.

Using Transact-SQL

For more information, see DROP DATABASE (Transact-SQL).

To delete a database

  1. Connect to the [!INCLUDEssDE].

  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 ;  
GO  

Follow Up: After deleting a database

Back up the master database. If master must be restored, any database that has been deleted since the last backup of master will still have references in the system catalog views and may cause error messages to be raised.

Limitations and Restrictions

Next steps