Print ''
Print '----------------------------------------------------'
Print ' Script for JobMgr:'
Print ' FirstVersion.: V2.0.0   30.12.2014 00:19'
Print ' CurrRevision.: '
Print ' Autor........: J.Feuerstein'
Print '----------------------------------------------------'
GO
use [#DB_N#]
GO

 declare @PGroupSourcePState nvarchar(14)
 declare @PGroupSourceXML_VAL xml
 declare @PGroupDestPState nvarchar(14)
 declare @PGroupDestXML_VAL xml
 declare @XML_VALTemp nvarchar(max)

 -- #ToDo: Set Source and dest PState
 set @PGroupSourcePState = 'ProcStateColRf'
 set @PGroupDestPState = 'ProcStateCol20'


 Print 'ProcessGroup copy Process Group settings'
 Print ' from:' + @PGroupSourcePState
 Print ' to..:' + @PGroupDestPState

 -- #Step: get Source Settings
 select @PGroupSourceXML_VAL = SerializedConfigObject from ProcessGroups_tbl where ProcStateCol = @PGroupSourcePState

 -- #Step: translate Settings
 set @XML_VALTemp = CONVERT(nvarchar(max), @PGroupSourceXML_VAL)
 set @XML_VALTemp = REPLACE(@XML_VALTemp,@PGroupSourcePState,@PGroupDestPState)
 set @PGroupDestXML_VAL = CONVERT(xml, @XML_VALTemp)
 --  print(@XML_VALTemp)

 -- #Step: Update Data
 UPDATE ProcessGroups_tbl
    SET SerializedConfigObject = @PGroupDestXML_VAL
    where ProcStateCol = @PGroupDestPState
GO


Print ''
Print '---------------------------------------------------------'
Print ' JobMgr Script executed'
Print '---------------------------------------------------------'
GO
