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 '-- [DS_AndProcessDataForCount_UDF_V1] ------------------------------------------------'
-- Cleanup del me after 10/2013
If Exists (select Name
           from sysobjects
            where Name = "DS_AndProcessDataForCount_UDF_V1" and type = "IF")
DROP FUNCTION DS_AndProcessDataForCount_UDF_V1
GO


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