USE [DBA] GO /****** Object: StoredProcedure [dbo].[SP_DROP_ALL_SNAPSHOTS] Script Date: 10/28/2015 11:21:36 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE Proc [dbo].[SP_DROP_ALL_SNAPSHOTS] as begin declare @sql table(stmt varchar(4000)) declare @stmt nvarchar(4000) insert @sql (stmt) select 'drop database '+name from sys.databases where source_database_id is not null declare sqlcursor cursor for select stmt from @sql open sqlcursor fetch next from sqlcursor into @stmt while @@FETCH_STATUS=0 begin --exec sp_executesql @stmt select @stmt exec sp_executesql @stmt fetch next from sqlcursor into @stmt end --select 'drop database '+name from sys.databases where source_database_id is not null end GO