SQL 批量删除Database
use master
declare @sql varchar(max)
declare @databasename varchar(max)
while exists(select name from sysdatabases where dbid>4)
begin
select top 1 @databasename=name from sysdatabases where dbid>4
if exists(select * from sysdatabases where dbid>4)
begin
print 'dropping database: '+@databasename
select @sql=+'DROP DATABASE ' + name + '; ' from sysdatabases where dbid>4;
exec (@sql)
end
end