| title | Delete a Database | Microsoft Docs | ||||||
|---|---|---|---|---|---|---|---|
| ms.custom | |||||||
| ms.date | 03/14/2017 | ||||||
| ms.prod | sql-server-2016 | ||||||
| ms.reviewer | |||||||
| ms.suite | |||||||
| ms.technology |
|
||||||
| ms.tgt_pltfrm | |||||||
| ms.topic | article | ||||||
| helpviewer_keywords |
|
||||||
| ms.assetid | 1fd8c0f5-03e1-449a-af45-b8cacb479d9c | ||||||
| caps.latest.revision | 31 | ||||||
| author | BYHAM | ||||||
| ms.author | rickbyh | ||||||
| manager | jhubbard |
This topic describes how to delete a user-defined database in [!INCLUDEssManStudioFull] in [!INCLUDEssCurrent] by using [!INCLUDEssManStudioFull] or [!INCLUDEtsql].
In This Topic
-
Before you begin:
-
To delete a database, using:
-
Follow Up: After deleting a database
- System databases cannot be deleted.
-
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.
- Consider taking a full backup of the database. A deleted database can be re-created only by restoring a backup.
To execute DROP DATABASE, at a minimum, a user must have CONTROL permission on the database.
-
In Object Explorer, connect to an instance of the [!INCLUDEssDEnoversion], and then expand that instance.
-
Expand Databases, right-click the database to delete, and then click Delete.
-
Confirm the correct database is selected, and then click OK.
-
Connect to the [!INCLUDEssDE].
-
From the Standard bar, click New Query.
-
Copy and paste the following example into the query window and click Execute. The example removes the
SalesandNewSalesdatabases.
USE master ;
GO
DROP DATABASE Sales, NewSales ;
GO 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.
CREATE DATABASE (SQL Server Transact-SQL)
ALTER DATABASE (Transact-SQL)