Drop Database with Active Connections - SQL Server

USE [master]
EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N'MyDatabase'
ALTER DATABASE [MyDatabase] SET  SINGLE_USER WITH ROLLBACK IMMEDIATE
DROP DATABASE [MyDatabase]