The DROP DATABASE command removes a database catalog, regardless of its state (offline, read-only, suspect, etc.), from the current SQL Server instance.
A database cannot be dropped if there are any database snapshots associated with it, as the database snapshots must be dropped first.
A database drop removes all of the physical disk files (unless it's offline) used by the database unless you use the Stored Procedure 'sp_detach_db'.
A database snapshot drop deletes the snapshot from the SQL Server instance and deletes the physical files also used by it.
A dropped database can only be re-created by restoring a backup (not from a database snapshot either).
The Syntax
DROP DATABASE [ IF EXISTS ] { database_name | database_snapshot_name } [ ,...n ] [;]
IF EXISTS
- Drop the table only if existsdatabase_name
- Specifies the name of the database to dropdatabase_snapshot_name
- Specifies the database snapshot to removeExamples
Remove a single database;
DROP DATABASE Database1;
Removing multiple databases
DROP DATABASE Database1, Database2;
Removing a snapshot
DROP DATABASE Database1_snapshot17;
Removing if database exists
DROP DATABASE IF EXISTS Database1;