I know this is an old post, but I myself was looking for an answer, and since I believe that the OP asked about deleting or deleting the database, and not about tables or content, I thought I would turn it on.
Both will delete the database, but both can include more than one step if you want to completely delete the database and related artifacts.
Delete
If you are using SQL Server Management Studio, you can delete the database by right-clicking on the database and selecting Delete. As a result, the dialog offers a couple of flags:
- 'Delete backup and restore history information for databases
- 'Close existing connections
If you do not check "Delete backup and recovery history", these files will remain on the server if you do not get rid of them manually. "Close existing connections" is a good idea, otherwise you may receive an error message when you are still using the database (even if you are just trying to delete it)
Drop
The SQL "DROP" command alone will not delete everything. You still need to delete the backup history and set the database to βone user modeβ - or it may complain that the database is still in use, as described above.
--Remove backup history EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'YourDBName' GO USE [master] GO --close all the open connections to your database ALTER DATABASE [YourDBName] SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO USE [master] GO --remove the actual database DROP DATABASE [YourDBName] GO
source share