- Sep 30, 2023
- 29
- 10
Code:
DECLARE @CodeNameOld VARCHAR(256) = 'MOB_CA_PERYTON_CLON'
DECLARE @CodeNameNew VARCHAR(256) = 'MOB_TQ_SNAKESLAVE_CLON2'
DECLARE @Table_01 TABLE ([dwTacticsID] INT) INSERT @Table_01 SELECT [Tab_RefTactics].[dwTacticsID] FROM [SRO_VT_SHARD].[dbo].[Tab_RefTactics] WITH(NOLOCK) JOIN [SRO_VT_SHARD].[dbo].[_RefObjCommon] WITH(NOLOCK) ON [Tab_RefTactics].[dwObjID] = [_RefObjCommon].[ID] WHERE [_RefObjCommon].[CodeName128] = @CodeNameOld
WHILE EXISTS (SELECT (1) FROM @Table_01)
BEGIN
DECLARE @TacticsIDOld INT = (SELECT TOP (1) [dwTacticsID] FROM @Table_01)
DECLARE @Table_02 TABLE ([dwTacticsID] INT) INSERT @Table_02 SELECT [Tab_RefTactics].[dwTacticsID] FROM [SRO_VT_SHARD].[dbo].[Tab_RefTactics] WITH(NOLOCK) JOIN [SRO_VT_SHARD].[dbo].[_RefObjCommon] WITH(NOLOCK) ON [Tab_RefTactics].[dwObjID] = [_RefObjCommon].[ID] WHERE [_RefObjCommon].[CodeName128] = @CodeNameNew
WHILE EXISTS (SELECT (1) FROM @Table_02)
BEGIN
DECLARE @TacticsIDNew INT = (SELECT TOP (1) [dwTacticsID] FROM @Table_02)
UPDATE [SRO_VT_SHARD].[dbo].[Tab_RefNest] SET [dwTacticsID] = @TacticsIDNew WHERE [dwTacticsID] = @TacticsIDOld
DELETE @Table_02 WHERE [dwTacticsID] = @TacticsIDNew
END
DELETE @Table_01 WHERE [dwTacticsID] = @TacticsIDOld
END