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

-- insert data to table

INSERT INTO [MIG_ROUTE_CHEKOUT_STP_PARAMS]

	select  TP.ROUTE_ID,
			TP.STEP_ID
	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_CheckOut' 
		AND TP.PRM_IDX = '1' 
	Order By TP.ROUTE_ID





