Skip to main content
How Can We Help?

Search for answers or browse our knowledge base.

Clone Parent Group with a new name

You are here:
< Back

This script will clone a parent group and all of the child groups to new names. The script will prepend a tilde ~, but you can prepend or append anything

BEGIN TRANSACTION;  
--create temp table from 'Theta' Group that you want to clone
Select * into #temp FROM(
Select [GroupName] ,[SQLText] , [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 = 'Theta'
 ) AS T
--Change the group names
 update  #temp set ParentGroupName = 'newparentgroup', GroupName = '~'+Groupname
--Create new groups by inserting into well groups
 Insert into tblWellGroups
 Select * from #temp
--preview your changes
 Select * from tblWellGroups where ParentGroupName = 'newparentgroup'
--remove temp table
 DROP TABLE #temp;
ROLLBACK;