DECLARE @sql VARCHAR (max)
DECLARE @DBname VARCHAR (50)
DECLARE DBS CURSOR FOR
SELECT name
FROM sys.databases
WHERE name NOT IN ( 'model', 'tempdb', 'master', 'model',
'reportserver', 'ReportServerDB', 'msdb')
OPEN DBS
FETCH next FROM DBS INTO @DBname
WHILE @@FETCH_STATUS = 0
BEGIN
SET @sql = 'DROP DATABASE ' + @DBname
PRINT @sql
--exec @sql
FETCH next FROM DBS INTO @DBname
END
CLOSE DBS
DECLARE @DBname VARCHAR (50)
DECLARE DBS CURSOR FOR
SELECT name
FROM sys.databases
WHERE name NOT IN ( 'model', 'tempdb', 'master', 'model',
'reportserver', 'ReportServerDB', 'msdb')
OPEN DBS
FETCH next FROM DBS INTO @DBname
WHILE @@FETCH_STATUS = 0
BEGIN
SET @sql = 'DROP DATABASE ' + @DBname
PRINT @sql
--exec @sql
FETCH next FROM DBS INTO @DBname
END
CLOSE DBS
DEALLOCATE DBS
No comments:
Post a Comment