Print ''
Print '----------------------------------------------------'
Print ' Update data table for JobMgr:'
Print ' FirstRevision: V2.0.0   22.03.2006'
Print ' CurrRevision : V2.1.1   10.01.2008'
Print ' Autor        : J.Feuerstein'
Print ' Database Name: #DB_N#'
Print '----------------------------------------------------'
GO

use [#DB_N#]
GO

Print '-------------------------------------------------------------------------'
Print ' Step (1/3): Get n Process Informations with lost processes'
GO
SELECT
  Count(*) AS [Lost Process Data to Cleanup]
FROM
  dbo.JobControl_ObjectsProcessData_tbl
WHERE
  dbo.JobControl_ObjectsProcessData_tbl.ProcessState = 'A'
  or dbo.JobControl_ObjectsProcessData_tbl.ProcessState like 'P%'
GO


Print '-------------------------------------------------------------------------'
Print ' Step (2/3): Deleting Process Informations with lost processes'
GO
DELETE
FROM
  dbo.JobControl_ObjectsProcessData_tbl
WHERE
  dbo.JobControl_ObjectsProcessData_tbl.ProcessState = 'A'
  or dbo.JobControl_ObjectsProcessData_tbl.ProcessState like 'P%'
GO

Print '-------------------------------------------------------------------------'
Print ' Step (3/3): ReOrg ProcessStatus Last Result'
Go
Execute ObjectsUpdate_ProcessStatus_Mark_LastRes__MaintainDB
Go

Print '.'
Print '------------------------------------------------------------------------'
Print (' performed on Database: #DB_N#')
Print '------------------------------------------------------------------------'
GO
