-- DROP TABLE [MIG_ROUTE_MODIFY_STP_PARAMS]
IF OBJECT_ID(N'dbo.MIG_ROUTE_MODIFY_STP_PARAMS', N'U') IS NULL
	BEGIN	
		CREATE TABLE [dbo].[MIG_ROUTE_MODIFY_STP_PARAMS](
			[ROUTE_ID] [varchar](30) NOT NULL,
			[STEP_ID] [varchar](15) NOT NULL,
			[MODIFICATION] [varchar](255) NOT NULL,
		 CONSTRAINT PK_MIG_ROUTE_MODIFY_STP_PARAMS PRIMARY KEY (ROUTE_ID, STEP_ID)
		) ON [PRIMARY]
	END
GO

-- insert data to table 

INSERT INTO [MIG_ROUTE_MODIFY_STP_PARAMS]

	select  TP.ROUTE_ID,
			TP.STEP_ID,
			TP.PRM_VALUE as MODIFICATION
	from	RT_TOOL_PRM TP
	LEFT JOIN NINTRA_TOOL NT
		ON TP.TOOL_KEY = NT.TOOL_KEY 
		AND TP.PRM_IDX = NT.PRM_IDX
	WHERE  NT.TOOL_KEY= 'WkFl_TOP' 
		AND TP.PRM_IDX = '1' 
	
	UNION

	SELECT  TP.ROUTE_ID,
			TP.STEP_ID,
			TP.PRM_VALUE as MODIFICATION
	FROM RT_TOOL_PRM TP 
	LEFT JOIN NINTRA_TOOL NT 
	ON TP.TOOL_KEY = NT.TOOL_KEY AND
		TP.PRM_IDX = NT.PRM_IDX 
	WHERE  TP.TOOL_KEY= 'WkFl_TOP_ToBAAN' 
			AND TP.PRM_IDX = '6'  -- MBC_ID 
		ORDER BY TP.ROUTE_ID
