Print ''
Print '-------------------------------------------------------------------------'
Print ' using Database: #DB_N#'
Print ' Action        : MaintainDatabase.sql'
Print ' Creation Date : 24.02.2009'
Print ' Autor         : J.Feuerstein'
Print '-------------------------------------------------------------------------'

use [#DB_N#]

DECLARE @Name nvarchar(64)
DECLARE @ValueCurr nvarchar(max)
DECLARE @ValueDesired nvarchar(max)
DECLARE @ValueCompareStat int
DECLARE @ExecuteSQLstr nvarchar(max)



Print ''
Print '-------------------------------------------------------------------------'
Print 'Maintain Database: #DB_N# !Start!'
Print '.........................................................................'
-- Update dbo.JobControl_ObjectsProcessData_tbl set dbo.JobControl_ObjectsProcessData_tbl.Row_isLastRes = NULL
-- Execute ObjectsUpdate_ProcessStatus_Mark_LastRes ''  -- '63bdd795-be19-4a07-93fb-f9260a8d3787' -- ''

Print 'Delete Temp Tables'
if (object_id('zztmpClean1_tbl') is not null)  Drop table zztmpClean1_tbl
if (object_id('zztmpClean2_tbl') is not null)  Drop table zztmpClean2_tbl
if (object_id('zztmpClean3_tbl') is not null)  Drop table zztmpClean3_tbl
if (object_id('zztmpClean4_tbl') is not null)  Drop table zztmpClean4_tbl
if (object_id('zztmpClean5_tbl') is not null)  Drop table zztmpClean5_


set @Name='ObjectsUpdate_ProcessStatus_Mark_LastRes__MaintainDB'
set @ValueCurr=''
set @ValueDesired='2009-02-23-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   print 'execute [ObjectsUpdate_ProcessStatus_Mark_LastRes__MaintainDB] Set to Stat:' + @ValueDesired + ' Start!'
   Execute ObjectsUpdate_ProcessStatus_Mark_LastRes__MaintainDB
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print 'execute [ObjectsUpdate_ProcessStatus_Mark_LastRes__MaintainDB] Set to Stat:' + @ValueDesired + ' DONE!'
 end

set @Name='JobControl_ObjectsProcessData_tbl_Update_ProcessResultHasWarning__MaintainDB'
set @ValueCurr=''
set @ValueDesired='2009-07-12-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE JobControl_ObjectsProcessData_tbl set ProcessResultHasWarning = 0 where ProcessResultHasWarning is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end

set @Name='JobControl_ObjectsProcessData_tbl_Update_ProcessResultLink__MaintainDB'
set @ValueCurr=''
set @ValueDesired='2009-07-12-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE JobControl_ObjectsProcessData_tbl set ProcessResultLink=' + '''' + '''' + ' where ProcessResultLink is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


set @Name='JobControlRules_tbl_Update_SelObjectsBy_PFM'
set @ValueCurr=''
set @ValueDesired='2009-10-21-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE JobControlRules_tbl set SelObjectsBy_PFM=1 where SelObjectsBy_PFM is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end

-- stellt sicher das ObjectUgMaster_PartFamMemName = '' und nicht NULL ist
set @Name='Objects_tbl_Update_ObjectUgMaster_PartFamMemName'
set @ValueCurr=''
set @ValueDesired='2009-10-21-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE Objects_tbl set ObjectUgMaster_PartFamMemName=' + '''' + '''' + ' where ObjectUgMaster_PartFamMemName is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end

set @Name='Sites_tbl_Update_DbConnectionTimeout'
set @ValueCurr=''
set @ValueDesired='2009-11-02-02'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE Sites_tbl set DbConnectionTimeout=60 where DbConnectionTimeout is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end



set @Name='Sites_tbl_Update_DbCommandTimeout'
set @ValueCurr=''
set @ValueDesired='2009-11-02-02'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE Sites_tbl set DbCommandTimeout=120 where DbCommandTimeout is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


set @Name='Sites_tbl_Update_ImportTc'
set @ValueCurr=''
set @ValueDesired='2010-07-08-04'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'

   print @Name + ' [Update:' + @ValueDesired + ' ->Start!]'
   set @ExecuteSQLstr='UPDATE Sites_tbl set ImportTcIrSearchMethode=1 where ImportTcIrSearchMethode is null'
   execute sp_executesql @ExecuteSQLstr
   print @Name + ' [Update 1/3:->DONE!] ' + @ExecuteSQLstr
   
   set @ExecuteSQLstr='UPDATE Sites_tbl set ImportTcObjectFs_DPNE=1 where ImportTcObjectFs_DPNE is null'
   execute sp_executesql @ExecuteSQLstr
   print @Name + ' [Update 2/3:->DONE!] ' + @ExecuteSQLstr

   set @ExecuteSQLstr='UPDATE Sites_tbl set ImportTcObjectFs_NE=1 where ImportTcObjectFs_NE is null'
   execute sp_executesql @ExecuteSQLstr
   print @Name + ' [Update 3/3:->DONE!] ' + @ExecuteSQLstr
   
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @Name + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end

-- rem wichtig @Name muss eindeutig sein
set @Name='Sites_tbl_Update_ImportApWithCompCound0AsSp'
set @ValueCurr=''
set @ValueDesired='2010-08-10-02'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   print @Name + ' [Update:' + @ValueDesired + ' ->Start!]'
   set @ExecuteSQLstr='UPDATE Sites_tbl set ImportApWithCompCound0AsSp=0 where ImportApWithCompCound0AsSp is null'
   execute sp_executesql @ExecuteSQLstr
   print @Name + ' [Update 1/1:->DONE!] ' + @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @Name + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


 -- rem wichtig @Name muss eindeutig sein
 set @Name='DataBase_BaseSettings'
 set @ValueCurr=''
 set @ValueDesired='2010-09-03-01'
 EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
 if @ValueCompareStat <> 1
 begin
 IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'#DB_N#')
   BEGIN
      -- neu 2.11.2009 einstellen nicht case sensitive
      ALTER DATABASE [#DB_N#] COLLATE Latin1_General_CI_AS
      Print '------------------------------------------------------------------'
      Print 'OK:Db:#DB_N#'
      Print '    set COLLATE = Latin1_General_CI_AS'

--       --  neu 03.09.2010
--       ALTER DATABASE [#DB_N#] SET ALLOW_SNAPSHOT_ISOLATION ON
--       Print '------------------------------------------------------------------'
--       Print 'OK:Db:#DB_N#'
--       Print '    set allow_snapshot_isolation on (03.09.2010)'
--
--       ALTER DATABASE [#DB_N#] SET READ_COMMITTED_SNAPSHOT ON
--       Print '------------------------------------------------------------------'
--       Print 'OK:Db:#DB_N#'
--       Print '    set READ_COMMITTED_SNAPSHOT ON (03.09.2010)'
      --------------- SQL ---------------
      EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
      print @Name + ' [Update:' + @ValueDesired + ' ->DONE!]'
   END
 end

 -- rem wichtig @Name muss eindeutig sein
 -- ItemsTbl CleanUp Aktion erstellt 11.01.2011 12:04 J.Fes
 set @Name='ItemsTbl_DeleteAllObjects'
 set @ValueCurr=''
 set @ValueDesired='2011-01-11-01'
 EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
 if @ValueCompareStat <> 1
 begin
  Print '-'
  Print '-- [delete function: ItemsTbl_ItemNameRev_GetDS] -------------------------------'
  If Exists (select Name from sysobjects where Name = "ItemsTbl_ItemNameRev_GetDS" and type = "P") Drop Procedure ItemsTbl_ItemNameRev_GetDS

  Print '-- [delete function: ItemsTbl_ItemNameRev_GetId] -------------------------------'
  If Exists (select Name from sysobjects where Name = "ItemsTbl_ItemNameRev_GetId" and type = "P") Drop Procedure ItemsTbl_ItemNameRev_GetId

  Print '-- [delete function: ItemsTblAddDataSet] -------------------------------'
  If Exists (select Name from sysobjects where Name = "ItemsTblAddDataSet" and type = "P") Drop Procedure ItemsTblAddDataSet

--         20: Drop Procedure ItemsTbl_ItemNameRev_GetDS
--      41: Drop Procedure ItemsTbl_ItemNameRev_GetId
--      93: Drop Procedure ItemsTblAddDataSet
  Print '-- [delete View: RefiledItemAndDataSets_View] ------------------------------'
  If Exists (select Name
           from sysobjects
            where Name = "RefiledItemAndDataSets_View" and type = "V")
  Drop View RefiledItemAndDataSets_View

  Print '-- [delete function: Items_tbl_DeleteDataRow_By_ID] ----------------------------'
  If Exists (select Name
             from sysobjects
             where Name = "items_tbl_DeleteDataRow_By_ID" and type = "P")
  Drop Procedure items_tbl_DeleteDataRow_By_ID

  Print '-- [delete function: ItemTblItemsToListView] -----------------------------------'
  If Exists (select Name
             from sysobjects
             where Name = "ItemTblItemsToListView" and type = "P")
  Drop Procedure ItemTblItemsToListView


  Print '-- [delete function: ItemsRefileResultsAddDataSet] -----------------------------'
  If Exists (select Name
             from sysobjects
             where Name = "ItemsRefileResultsAddDataSet" and type = "P")
  Drop Procedure ItemsRefileResultsAddDataSet


  Print '-- [delete function: ItemsRev_RefileProcessState_Set] --------------------------'
  If Exists (select Name
             from sysobjects
             where Name = "ItemsRev_RefileProcessState_Set" and type = "P")
  Drop Procedure ItemsRev_RefileProcessState_Set

  Print '-- [delete function: ItemsRefileResults_GetId] ---------------------------------'
  If Exists (select Name
             from sysobjects
             where Name = "ItemsRefileResults_GetId" and type = "P")
  Drop Procedure ItemsRefileResults_GetId

  --  delete Items_tbl 11.01.2011
  if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Items_tbl]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  BEGIN
   Print '-- [delete: Table:Items_tbl] ---------------------------------'
   DROP TABLE [dbo].[Items_tbl]
  END


  --  delete ItemsRefileResults_tbl 11.01.2011
  if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ItemsRefileResults_tbl]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  BEGIN
   Print '-- [delete: Table:ItemsRefileResults_tbl] ---------------------------------'
   DROP TABLE [dbo].[ItemsRefileResults_tbl]
  END

  EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
  print @Name + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


 -- rem wichtig @Name muss eindeutig sein
 -- ItemsTbl CleanUp Aktion erstellt 11.01.2011 12:04 J.Fes
 set @Name='Objects_tbl_DeleteDataRow_By_ID-Remove'
 set @ValueCurr=''
 set @ValueDesired='2011-03-04-01'
 EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
 if @ValueCompareStat <> 1
 begin
  Print '-- [Objects_tbl_DeleteDataRow_By_ID] ------------------------------------'
  If Exists (select Name
             from sysobjects
             where Name = "Objects_tbl_DeleteDataRow_By_ID" and type = "P")
             Drop Procedure Objects_tbl_DeleteDataRow_By_ID

  EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
  print @Name + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


set @Name='Sites_tbl_Update_OracleTblNameInfodbaReplace'
set @ValueCurr=''
set @ValueDesired='2011-03-07-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE Sites_tbl set OracleTblNameInfodbaReplace=' + ''''  + '''' + ' where OracleTblNameInfodbaReplace is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end

set @Name='Sites_tbl_Update_Tns_Admin_Add_TnsNames.Ora'
set @ValueCurr=''
set @ValueDesired='2011-10-30-02'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE dbo.Sites_tbl set Tns_Admin=[Tns_Admin] + ' + '''' + '\tnsnames.ora'  + ''''  +
                      ' WHERE' +
                       ' dbo.Sites_tbl.Tns_Admin <> ' + '''' + '''' + ' AND' +
                       ' dbo.Sites_tbl.Tns_Admin NOT LIKE ' + '''' + '%\%.ora' + '''' + ' AND' +
                       ' dbo.Sites_tbl.Tns_Admin IS NOT NULL'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


set @Name='JobControlRules_tbl_Update_SelObjectsBy_FsHitCount_YN'
set @ValueCurr=''
set @ValueDesired='2011-10-31-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE JobControlRules_tbl set SelObjectsBy_FsHitCount_YN=0 where SelObjectsBy_FsHitCount_YN is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


set @Name='JobControlRules_tbl_Update_JobResourcePoints'
set @ValueCurr=''
set @ValueDesired='2011-10-31-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE JobControlRules_tbl set JobResourcePoints=0 where JobResourcePoints is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end

set @Name='JobControlRules_tbl_Update_JobResult_ProcStateValueRule'
set @ValueCurr=''
set @ValueDesired='2011-10-31-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE JobControlRules_tbl set [JobResult_ProcStateValueRule]=' + '''' + '''' + ' where [JobResult_ProcStateValueRule] is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


set @Name='ImportTcApBomLineUgGometryNo_DoCount'
set @ValueCurr=''
set @ValueDesired='2011-08-11-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   print @Name + ' [Update:' + @ValueDesired + ' ->Start!]'
   set @ExecuteSQLstr='UPDATE Sites_tbl set ImportTcApBomLineUgGometryNo_DoCount=1 where ImportTcApBomLineUgGometryNo_DoCount is null'
   execute sp_executesql @ExecuteSQLstr
   print @Name + ' [Update 1/1:->DONE!] ' + @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @Name + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


-- Reset ObjectType for Dataset from Objects_tbl where ObjectClass = "IR"
set @Name='Objects_tbl_Update_IRS_ObjectType_RESET'
set @ValueCurr=''
set @ValueDesired='2012-02-03-02'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE Objects_tbl set ObjectType=' + '''~''' + ' where ObjectClass=''IR'' and ObjectType in (''~'',''UGMASTER'',''UGPART'',''UGALTREP'',''UGMANIFESTATION'',''UGSCENARIO'',''NXSIMULATION'',''CAEGEOM'',''CAEMESH'',''CAESOLUTION'')'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end

-- #New: 13.10.2012 J.Fes
set @Name='JobControlRules_tbl_Update_JobPacket_ContainOnlyObjOfDiffrentI'
set @ValueCurr=''
set @ValueDesired='2012-10-13-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE JobControlRules_tbl set [JobPacket_ContainOnlyObjOfDiffrentI]=0 where [JobPacket_ContainOnlyObjOfDiffrentI] is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end


-- #New: 13.10.2012 J.Fes
-- set @Name='JobControlRules_tbl_Update_JobPacket_ContainOnlyObjOfDiffrentIR'
-- set @ValueCurr=''
-- set @ValueDesired='2012-10-13-02'
-- EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
-- if @ValueCompareStat <> 1
--  begin
--    print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
--    set @ExecuteSQLstr='UPDATE JobControlRules_tbl set [JobPacket_ContainOnlyObjOfDiffrentIR]=0 where [JobPacket_ContainOnlyObjOfDiffrentIR] is null'
--    print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
--    execute sp_executesql @ExecuteSQLstr
--    EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
--    print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
--  end


-- #New: 13.10.2012 J.Fes
set @Name='JobControlRules_tbl_Update_JobPacket_JobSumObjectCount'
set @ValueCurr=''
set @ValueDesired='2011-10-31-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE JobControlRules_tbl set JobPacket_JobSumObjectCount=0 where JobPacket_JobSumObjectCount is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end

-- #New: 13.10.2012 J.Fes
set @Name='JobControlRules_tbl_Update_SelObjectsBy_Status'
set @ValueCurr=''
set @ValueDesired='2011-10-31-01'
EXECUTE zzzzzDbMaintain_valueGet @Name , @ValueCurr Output , @ValueDesired , @ValueCompareStat Output
if @ValueCompareStat <> 1
 begin
   print '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'
   set @ExecuteSQLstr='UPDATE JobControlRules_tbl set [SelObjectsBy_Status]=' + '''' + '''' + ' where [SelObjectsBy_Status] is null'
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->Start!]'
   execute sp_executesql @ExecuteSQLstr
   EXECUTE zzzzzDbMaintain_valueSave @Name , @ValueDesired
   print @ExecuteSQLstr + ' [Update:' + @ValueDesired + ' ->DONE!]'
 end

EndeExit:
 Print '.........................................................................'
 Print ('Maintain Database: #DB_N# !Done!')
 Print '-------------------------------------------------------------------------'
 Print ''
GO
