Copy Sales Pad Security Setting Copy Work Flow Setting

SET NOCOUNT ON

--Move the groups user tie 
SELECT * INTO ARCHV.._spSystemUser_pre_update FROM ARCHV..spSystemUser 
GO 
DELETE FROM ARCHV..spSystemUser 
GO 
INSERT INTO ARCHV..spSystemUser SELECT * FROM MTHND..spSystemUser 
GO 
--DROP TABLE ARCHV.._spSystemUser_pre_update 

--Move the groups user tie 
SELECT * INTO ARCHV.._spSystemUserMembership_pre_update FROM ARCHV..spSystemUserMembership 
GO 
DELETE FROM ARCHV..spSystemUserMembership 
GO 
INSERT INTO ARCHV..spSystemUserMembership SELECT * FROM MTHND..spSystemUserMembership 
GO 
--DROP TABLE ARCHV.._spSystemUserMembership_pre_update 

--Move the groups 
SELECT * INTO ARCHV.._spSystemGroup_pre_update FROM ARCHV..spSystemGroup 
GO 
DELETE FROM ARCHV..spSystemGroup 
GO 
INSERT INTO ARCHV..spSystemGroup SELECT * FROM MTHND..spSystemGroup 
GO 
--DROP TABLE ARCHV.._spSystemGroup_pre_update 

--Move the security 
SELECT * INTO ARCHV.._spSystemSecurity_pre_update FROM ARCHV..spSystemSecurity 
GO 
DELETE FROM ARCHV..spSystemSecurity 
GO 
INSERT INTO ARCHV..spSystemSecurity SELECT * FROM MTHND..spSystemSecurity 
GO 
--DROP TABLE ARCHV.._spSystemSecurity_pre_update 

--Move the Settings 
set Identity_Insert ARCHV..spUserSetting OFF
GO
INSERT INTO ARCHV..spUserSetting(userName, settingKey, value, String_Value)
GO
SELECT userName, settingKey,value,String_Value FROM MTHND..spUserSetting
GO
set Identity_Insert ARCHV..spUserSetting ON
GO
--DROP TABLE ARCHV.._spUserSetting_pre_update 

--Move the Userfield definitions 
SELECT * INTO ARCHV.._spUserField_pre_update FROM ARCHV..spUserField 
GO 
DELETE FROM ARCHV..spUserField 
GO 
INSERT INTO ARCHV..spUserField SELECT * FROM MTHND..spUserField 
GO 
--DROP TABLE ARCHV.._spUserField_pre_update 

--Move the Workflow Queues 
Select * into ARCHV.._spWorkflow_pre_update from ARCHV..spWorkflow 
GO 
Drop Table ARCHV..spWorkflow 
GO 
Select * into ARCHV..spWorkflow from MTHND..spWorkflow 
GO 
--DROP TABLE ARCHV.._spWorkflow_pre_update 

--Move the WF conditions 
SELECT * INTO ARCHV.._spWorkflowCondition_pre_update FROM ARCHV..spWorkflowCondition 
GO 
Delete FROM ARCHV..spWorkflowCondition 
GO 
INSERT INTO ARCHV..spWorkflowCondition SELECT * FROM MTHND..spWorkflowCondition 
GO 
--DROP TABLE ARCHV.._spWorkflowCondition_pre_update 

delete from ARCHV..spWorkflowRule 
delete from ARCHV..spWorkflowConfiguredCondition 
set Identity_Insert ARCHV..spWorkflowRule on; 
INSERT INTO 
ARCHV..spWorkflowRule (Rule_ID,Sales_Doc_Type,Sales_Doc_ID,Sequence,Description,Enabled,Eval_When_In_Queue,Reevaluate_When_Line_Changes,Reevaluate_When_Header_Changes,Apply_Hold,Move_To_Queue) 
SELECT 
Rule_ID,Sales_Doc_Type,Sales_Doc_ID,Sequence,Description,Enabled,Eval_When_In_Queue,Reevaluate_When_Line_Changes,Reevaluate_When_Header_Changes,Apply_Hold,Move_To_Queue 
from MTHND..spWorkflowRule 
set Identity_Insert ARCHV..spWorkflowRule off; 
set Identity_Insert ARCHV..spWorkflowConfiguredCondition on; 
INSERT INTO 
ARCHV..spWorkflowConfiguredCondition (Rule_ID 
,Condition_ID 
,[Enabled] 
,Parameters 
,[Description] 
,Seq 
,Row_ID) 
SELECT 
Rule_ID 
,Condition_ID 
,[Enabled] 
,Parameters 
,[Description] 
,Seq 
,Row_ID 
from 
MTHND..spWorkflowConfiguredCondition 
set Identity_Insert ARCHV..spWorkflowConfiguredCondition off; 
delete from ARCHV..spSystemReport 
--set Identity_Insert ARCHV..spSystemReport on; 
INSERT INTO 
ARCHV..spSystemReport (ReportGroup 
,ReportID 
,ReportName 
,Layout 
,Visible) 
SELECT 
ReportGroup 
,ReportID 
,ReportName 
,Layout 
,Visible 
from 
MTHND..spSystemReport 
--set Identity_Insert ARCHV..spSystemReport off; 
SET NOCOUNT off 

Leave a Reply