Skip to main content
How Can We Help?

Search for answers or browse our knowledge base.

Copy group to new parent

You are here:
< Back

Create a Parent group, edit the correct parent group name, and new parent group name. then run script

BEGIN TRANSACTION;  

Select * into #temp FROM(
--new Parent group name
Select [GroupName] ,[SQLText] ,'~Loop' AS ParentGroupName ,[ShutdownFlag],[ShutdownStartDate] ,[ShutdownEndDate] ,[StartupFlag] ,[StartupStartDate] ,[StartupEndDate] ,[DrillDown] ,[FacGroup] ,[Priority] ,[FilterID] ,[ViewID] ,[Locked] ,[SuspendPorts] ,[EnableEquipmentDownload] ,[AllowStartFlag] ,[AllowStartLock] ,[ScoreValue] ,[LastRefreshed] ,[RefreshTimeout] ,[EnableEquipmentUpload]
 from tblWellGroups 
 
 where ParentGroupName = 'Loop' --Parent group you want to copy
 ) AS T
--Change the group name here.
 update  #temp set ParentGroupName = '~Loop', GroupName = '~'+Groupname
-- Select * from #temp
 
 Insert into tblWellGroups
  Select * from #temp 

 Select * from tblWellGroups where ParentGroupName = '~Loop' --this needs to match the new Parent group name
 DROP TABLE #temp;
ROLLBACK;