EXEC sp_MSforeachdb ‘
IF DB_ID(”?”) > 4
BEGIN
ALTER DATABASE ? SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DROP DATABASE ?
END’

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.