--EXEC MIG_EO_TEXTS_Sp
CREATE OR ALTER PROCEDURE MIG_EO_TEXTS_Sp 
AS
BEGIN

	DELETE FROM MIG_EO_TEXTS

	INSERT INTO MIG_EO_TEXTS (ZZ_ID, EO_ID, TEXT_ID_IMPA, TEXT_ID_RSCH, TEXT_ID_RMRK)
	SELECT	EO.ZZ_ID, 
			EO.EO_ID, 
			IMPA.TEXT_ID AS impa,
			RSCH.TEXT_ID AS rsch,
			RMRK.TEXT_ID AS rmrk
	FROM EO 
	JOIN MIG_TEXTS IMPA
		ON EO.ZZ_ID = IMPA.ZZ_ID AND IMPA.TABLE_NAME = 'pdwfl100' AND IMPA.FIELD_NAME='impa'
	JOIN MIG_TEXTS RSCH
		ON EO.ZZ_ID = RSCH.ZZ_ID AND RSCH.TABLE_NAME = 'pdwfl100' AND RSCH.FIELD_NAME='rsch'
	JOIN MIG_TEXTS RMRK
		ON EO.ZZ_ID = RMRK.ZZ_ID AND RMRK.TABLE_NAME = 'pdwfl100' AND RMRK.FIELD_NAME='rmrk'
	
END
