Print ''
Print '---------------------------------------------------------------------------------------'
Print ' using Database: #DB_N#'
Print ' Procedures    : [REPORTS_ListOfReports]'
Print ' Creation      : 29.08.2013/J.Fes'
Print ' Last.Update   : 29.08.2013/J.Fes'

use [#DB_N#]

Print ''
Print '---------------------------------------------------------------------------------------'
Print '--------------------- R E P O R T S - Clean Up ----------------------------------------'

-- 26.02.2010 16:52 #temp_tbl loeschen da sonst bei abbruch die Reports nicht importiert werden koennen!!
IF (OBJECT_ID ('tempdb..##temp_tbl', N'U') IS NOT NULL) exec ('drop table ##temp_tbl')
GO

Print '-- [Report_CleanUp for Update] --------------------------------------------------------'
Declare @ReportToDelete nvarchar(4000)
Declare @ReportToDeleteExce nvarchar(4000)
While (SELECT TOP 1 Name FROM sysobjects
       WHERE ([Name] LIKE 'Report[_]%' or [Name] LIKE 'Rrt[_]%') AND type = 'P') <> ""

 begin
  select Top(1) @ReportToDelete=Name from sysobjects
   WHERE ([Name] LIKE 'Report[_]%' or [Name] LIKE 'Rrt[_]%') AND type = 'P'
   Print '    |-- Report:' + @ReportToDelete
  set @ReportToDeleteExce="Drop PROCEDURE " + @ReportToDelete
  execute (@ReportToDeleteExce)
 end
GO



Print '--------------------- R E P O R T S - Clean Up DONE -----------------------------------'
