Skip to content
Related Articles

Related Articles

Improve Article

Delete Database in MS SQL Server

  • Last Updated : 02 Sep, 2020

Prerequisite – Introduction of MS SQL Server and Create Database in MS SQL Server

System databases can’t be deleted, only user databases could be deleted. Data and log files will automatically be deleted from disk with database deletion.

To delete a database, the below methods could be used –

  1. SQL Server Management Studio.
  2. Transact-SQL.

These are explained as following below.

1. Using SQL Server Management Studio :
To delete a database, connect to an instance of the SQL Server, and then expand that instance.

Expand Databases, select the database which need to be deleted.

Right-click the database which need to be deleted, and then click Delete.

Check delete backup and restore history or close existing connections if required and then click OK.

2. Using Transact-SQL :
To execute DROP DATABASE statement a user must have CONTROL permission on the database.

  • To delete a database :
    USE master ;  
    DROP DATABASE Databasename;  
  • To delete multiple databases :
    USE master ;  
    DROP DATABASE database1, database2, ...;  

Example :
Let us assume we have created a database “Geekstest” which is no longer required, to delete database :

USE master ;

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

My Personal Notes arrow_drop_up
Recommended Articles
Page :