﻿GO
SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;

SET NUMERIC_ROUNDABORT OFF;


GO
PRINT N'INSERT INTO [T_KEPESITES] FROM [T_DICTIONARY] a hianyzokat a SzakTipus tipusbol';


GO
INSERT INTO T_KEPESITES (C_KEPESITESTIPUSID, C_INTEZMENYID, C_TANEVID, TOROLT)
SELECT
   ID
  ,C_INTEZMENYID
  ,C_TANEVID
  ,TOROLT 
FROM T_DICTIONARYITEMBASE 
WHERE C_TYPE = 'SzakTipus' AND NOT EXISTS (
	SELECT 1 
	FROM T_KEPESITES 
	WHERE T_KEPESITES.C_KEPESITESTIPUSID = T_DICTIONARYITEMBASE.ID 
		AND T_KEPESITES.C_INTEZMENYID= T_DICTIONARYITEMBASE.C_INTEZMENYID 
		AND T_KEPESITES.C_TANEVID= T_DICTIONARYITEMBASE.C_TANEVID
		AND T_KEPESITES.TOROLT= T_DICTIONARYITEMBASE.TOROLT
)

GO


