-- EXEC MIG_ITEM_ONLY_2_Sp
CREATE OR ALTER PROCEDURE MIG_ITEM_ONLY_2_Sp
AS
BEGIN
	DELETE FROM MIG_ITEM_ONLY_2

	INSERT INTO MIG_ITEM_ONLY_2
	(
		[ITEM_KEY],
		[ZZ_ID_MAX]
	)
	SELECT DISTINCT 
		 STM.ITEM_KEY
		,MAX(STM.ZZ_ID) AS "ZZ_ID_MAX" 
	FROM ITEM STM 
	WHERE STM.OBJECT_TYPE = '0'
	GROUP BY STM.ITEM_KEY

END
