Print ''
Print '-------------------------------------------------------------------------'
Print ' using Database: #DB_N#'
Print ' Action        : CleanUp Database'
Print ' Creation Date : 21.01.2006'
Print ' Autor         : J.Feuerstein'
Print ' '
Print '-------------------------------------------------------------------------'

use [#DB_N#]


-- 21.01.2009 J.Fes CleanUp via Delete tempTables witch where used in ObjectsAndProcessData
If Exists (select Name from sysobjects where Name = "zzzzzDebugTbl_Empty" and type = "P")
begin
 print 'cleanup zzzzzDebugTbl via zzzzzDebugTbl_Empty'
 EXECUTE zzzzzDebugTbl_Empty
end

IF OBJECT_ID ('zztmpERG_tbl', N'U')  IS NOT NULL Drop table zztmpERG_tbl
IF OBJECT_ID ('zztmpMAX_tbl', N'U')  IS NOT NULL Drop table zztmpMAX_tbl
IF OBJECT_ID ('zztmpObj_tbl', N'U')  IS NOT NULL Drop table zztmpObj_tbl
IF OBJECT_ID ('zztmpObj2_tbl', N'U') IS NOT NULL Drop table zztmpObj2_tbl

if (object_id('tempdb..#zztmpERG_tbl') is not null)  Drop table #zztmpERG_tbl

If Exists (select Name from sysobjects where Name = "ObjectsAndProcessData_View" and type = "V")
 begin
    Print 'Drop: [ObjectsAndProcessData_View] 28.01.2009 J.Fes '
    Drop View ObjectsAndProcessData_View
 end
 
If Exists (select Name from sysobjects where Name = "ObjectsDataSets_View" and type = "V")
 begin
    Print 'Drop: [ObjectsDataSets_View] 28.01.2009 J.Fes --> ersetzt durch DS_with_Irs_View'
    Drop View ObjectsDataSets_View
 end

If Exists (select Name from sysobjects where Name = "ObjectsIRs_View" and type = "V")
 begin
    Print 'Drop: [ObjectsIRs_View] 28.01.2009 J.Fes '
    Drop View ObjectsIRs_View
 end

If Exists (select Name from sysobjects where Name = "IrId_DsId_View" and type = "V")
 begin
    Print 'Drop: [IrId_DsId_View] 28.01.2009 J.Fes '
    Drop View IrId_DsId_View
 end

If Exists (select Name
           from sysobjects
            where Name = "DS_AndProcessData_View" and type = "V")
 begin
  print 'Drop View DS_AndProcessData_View 2.3.09 J.Fes'
  Drop View DS_AndProcessData_View
 end


-----------------------------------------------------------------------------
If Exists (select Name
           from sysobjects
            where Name = "IRs_AndProcessData_View" and type = "V")
 begin
  print 'Drop View IRs_AndProcessData_View 2.3.09 J.Fes'
  Drop View IRs_AndProcessData_View
 end



GO


EndeExit:
 Print ''
 Print '--'
 Print ('CleanUp Done on Database: #DB_N#')
 Print '------------------------------------------------------------------------'
GO
