RSS

Drop Database # Script

04 Jun

USE master
GO

DECLARE @DBNAME VARCHAR(50)

SET @DBNAME = ‘HD’

DECLARE @HoldSql VARCHAR(500)

EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = @DBNAME

SET @HoldSql = ‘ALTER DATABASE [‘ + @DBNAME + ‘] SET SINGLE_USER WITH ROLLBACK IMMEDIATE’

EXECUTE (@HoldSql)

SET @HoldSql = ‘DROP DATABASE [‘ + @DBNAME + ‘]’

EXECUTE (@HoldSql)

if you need to know How to Drop all Databases in your Server Check this link

http://wp.me/p1Oidq-c8

 
Leave a comment

Posted by on June 4, 2013 in Script

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s