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

-- insert data to table

INSERT INTO [MIG_EO_MODIFY_STP_PARAMS]

	select  TP.EO_ID,
			TP.ROUTE_ID,
			TP.STEP_ID,
			TP.PRM_VALUE as MODIFICATION
	from	EO_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.EO_ID,
			TP.ROUTE_ID,
			TP.STEP_ID,
			TP.PRM_VALUE as MODIFICATION
	from	EO_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_ToBAAN' 
		AND TP.PRM_IDX = '6'  -- MBC_ID 
	ORDER BY TP.EO_ID
	
