﻿INSERT INTO T_TANTERV (
	C_CSOPORTTIPUSA
	,C_EVFOLYAMIG
	,C_EVFOLYAMTOL
	,C_KERETTANTERVREEPULO
	,C_MEGJEGYZES
	,C_NEV
	,C_INTEZMENYID
	,C_TANEVID
	,TOROLT
	,SERIAL
	,LASTCHANGED
	,CREATED
	,MODIFIER
	,CREATOR
)
SELECT 
	1034
   ,1303
   ,1310
   ,'F'
   ,''
   ,'Kerettanterv'
   ,tn.C_INTEZMENYID
   ,tn.ID
   ,'F'
   ,0
   ,GETDATE()
   ,GETDATE()
   ,NULL
   ,NULL
FROM T_TANEV tn
WHERE
	tn.C_NEV='2019/2020' AND TOROLT='F'
	AND NOT EXISTS(
		SELECT 1 FROM T_TANTERV WHERE C_TANEVID = tn.ID AND TOROLT = 'F' AND C_NEV = 'Kerettanterv'
	)