Just to clarify, ths isn\'t really a question, more some help for people like me who were looking for an answer.
A lot of applications create temp tables and the like, b
There is no need to use a cursor, and no need to copy and paste SQL statements. Just run these two lines:
DECLARE @Sql as NVARCHAR(MAX) = (SELECT 'DROP DATABASE ['+ name + ']; ' FROM sys.databases WHERE name LIKE 'DBName%' FOR XML PATH(''))
EXEC sys.sp_executesql @Sql
Of course, any DB matching the criteria will be dropped immediately, so be sure that you know what you are doing.