﻿INSERT INTO T_TANEV (
C_AKTIV
,C_ELSOTANITASINAP
,C_KEZDONAP
,C_KOVETKEZO
,C_NEV
,C_SORSZAM
,C_UTOLSONAP
,C_UTOLSOTANITASINAP
,C_AKTIVALVA
,C_DEFAULTFELADATKATEGORIAID
,C_INTEZMENYID
,TOROLT
,SERIAL
,LASTCHANGED
,CREATED
,MODIFIER
,CREATOR
,ELOZOTANEVIREKORDID
,NNID
,C_ISKIVALASZTHATO
) SELECT
'F' AS C_AKTIV
,'20190902' AS C_ELSOTANITASINAP
,'20190901' AS C_KEZDONAP
,'F' AS C_KOVETKEZO
,'2019/2020' AS C_NEV
,38 AS C_SORSZAM
,'20200831' AS C_UTOLSONAP
,'20200615' AS C_UTOLSOTANITASINAP
,NULL AS C_AKTIVALVA
,7553 AS C_DEFAULTFELADATKATEGORIAID
,i.ID AS C_INTEZMENYID
,'F' AS TOROLT
,0 AS SERIAL
,GETDATE() AS LASTCHANGED
,GETDATE() AS CREATED
,NULL AS MODIFIER
,NULL AS CREATOR
,NULL AS ELOZOTANEVIREKORDID
,NULL AS NNID
,'F' AS C_ISKIVALASZTHATO
FROM T_INTEZMENY i
WHERE C_FENNTARTOAZONOSITO < 900
AND NOT EXISTS (
SELECT 1 FROM T_TANEV tv
WHERE tv.C_NEV = '2019/2020' AND tv.C_INTEZMENYID = i.ID
)
