This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| declare @sql nvarchar(max) = | |
| (select string_agg(concat('alter database ', quotename(name), ' set single_user with rollback immediate; drop database ', quotename(name), ';'), char(13)) | |
| from sys.databases | |
| where database_id > 4); | |
| EXEC sp_executesql @sql; |