Print ''
Print '========================================================================='
Print ' Delete all JobResults and Reset ProcessStatus to:N'
Print ' Autor        : J.Feuerstein'
Print '========================================================================='


use [#DB_N#]

declare @ExecuteMsgRf    varchar(max)
declare @ExecuteSQLstrRf varchar(max)

declare @ExecuteMsg      varchar(max)
declare @ExecuteSQLstr   varchar(max)

Print 'Database: #DB_N#'
Print '-------------------------------------------------------------------------'


Print 'all Data from Table: JobControl_ObjectsProcessData_tbl'
TRUNCATE TABLE [dbo].[JobControl_ObjectsProcessData_tbl]

Print '-------------------------------------------------------------------------'
set @ExecuteMsgRf='Reset Process Status:[ProcStateColRf] to N'

set @ExecuteSQLstrRf='UPDATE Objects_tbl SET ProcStateColRf = ' + '''' + 'N' + '''' + ' where (ProcStateColRf not in (' + '''' + 'X' + '''' + ',' + '''' + 'N' + '''' + '))'
Print @ExecuteMsgRf
print 'via:' + @ExecuteSQLstrRf
exec (@ExecuteSQLstrRf)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol01')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol01')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol01')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol01')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol02')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol02')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol03')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol03')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol04')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol04')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol05')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol05')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol06')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol06')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol07')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol07')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol08')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol08')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol09')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol09')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)

set @ExecuteMsg    = REPLACE(@ExecuteMsgRf,    'ProcStateColRf','ProcStateCol10')
set @ExecuteSQLstr = REPLACE(@ExecuteSQLstrRf, 'ProcStateColRf','ProcStateCol10')
print @ExecuteMsg
print 'via:' + @ExecuteSQLstr
exec (@ExecuteSQLstr)


Print '========================================================================='
Print ' End of Script'
Print '========================================================================='
GO
