20

I want to delete some SQL Databases on my server, but I'm having problems. My login has the roles:

  • public
  • dbcreator
  • serveradmin

When I right click the database and hit Delete, it says that

Delete backup history failed for server 'MYSERVER' (Microsoft.SqlServer.Smo)
Additional Information: The EXECUTE permission was denied on the object 'sp_delete_database_backuphistory'

How do I delete these databases?

rlb.usa
  • 14,942
  • 16
  • 80
  • 128

3 Answers3

23

enter image description here

Please uncheck the "Delete Backup and restore history information for databases" then click the OK button.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
baazi shaik
  • 231
  • 2
  • 2
19

do you get the same problem when executing it from a query window like this?

DROP DATABASE DatabaseName
SQLMenace
  • 132,095
  • 25
  • 206
  • 225
  • 4
    If you get the an error that there is a connection in use then select the master database as executing database. Or use this code: `USE Master; GO DROP DATABASE AdventureWorks; GO` – LockTar Apr 03 '14 at 05:45
  • 1
    That doesn't work for me. `Incorrect syntax was encountered while parsing GO.` – nwalke Sep 25 '14 at 16:00
  • Sometimes I'm amazed how things work out of logic. Using the delete database UI in `SSMS` doesn't work but executing the command it works! Amazing really! ;) I'd never think about doing this... hehehe – Leniel Maccaferri Feb 28 '15 at 02:44
  • @LockTar's command works perfectly, if you leave off the `GO` parts. Disconnect and reconnect to see the database gone from the Object Explorer. – Jonathan E. Landrum Aug 11 '21 at 20:52
  • Cannot drop database "Db_Name" because it is currently in use. – nafischonchol Aug 18 '22 at 13:54
2

The only thing that worked for me was to:

1) Run SSMS as Administrator

2) Login using the master user(which would be sa in most cases). This is the user that you specified when installing Sql Server.

After the above mentioned steps, I was able to delete the database even without unchecking the backup checkbox!

Syed Waqas
  • 2,576
  • 4
  • 29
  • 36