方案1:
declare @sql varchar(8000)
Select @sql=isnull(@sql, ' ')+ 'drop database '+name+char(13)
from master..sysdatabases where name like 'system% '
exec(@sql)
方案2:
declare @var varchar(1000)
set @var= ' '
select @var=@var+ 'drop database '+name+char(13) from sysdatabases where name like 'System_% '
print @var
--exec(@var)