﻿DISABLE TRIGGER tr_cimLog ON T_CIM

UPDATE cim
SET cim.C_FELHASZNALOID = tanulo.ID, cim.LASTCHANGED = GETDATE()
FROM T_CIM cim
INNER JOIN T_GONDVISELO gondviselo ON gondviselo.ID = cim.C_GONDVISELOID AND gondviselo.C_TANEVID = cim.C_TANEVID AND gondviselo.C_INTEZMENYID = cim.C_INTEZMENYID
INNER JOIN T_TANULO tanulo ON tanulo.ID = gondviselo.C_TANULOID AND tanulo.C_ALTANEVID = gondviselo.C_TANEVID AND tanulo.C_ALINTEZMENYID = gondviselo.C_INTEZMENYID
WHERE cim.C_FELHASZNALOID IS NULL

GO
ENABLE TRIGGER tr_cimLog ON T_CIM
GO

DISABLE TRIGGER tr_emailLog ON T_EMAIL

UPDATE mail
SET mail.C_FELHASZNALOID = tanulo.ID, mail.LASTCHANGED = GETDATE()
FROM T_EMAIL mail
INNER JOIN T_GONDVISELO gondviselo ON gondviselo.ID = mail.C_GONDVISELOID AND gondviselo.C_TANEVID = mail.C_TANEVID AND gondviselo.C_INTEZMENYID = mail.C_INTEZMENYID
INNER JOIN T_TANULO tanulo ON tanulo.ID = gondviselo.C_TANULOID AND tanulo.C_ALTANEVID = gondviselo.C_TANEVID AND tanulo.C_ALINTEZMENYID = gondviselo.C_INTEZMENYID
WHERE mail.C_FELHASZNALOID IS NULL

GO
ENABLE TRIGGER tr_emailLog ON T_EMAIL
GO

DISABLE TRIGGER tr_telefonLog ON T_TELEFON

UPDATE telefon
SET telefon.C_FELHASZNALOID = tanulo.ID, telefon.LASTCHANGED = GETDATE()
FROM T_TELEFON telefon
INNER JOIN T_GONDVISELO gondviselo ON gondviselo.ID = telefon.C_GONDVISELOID AND gondviselo.C_TANEVID = telefon.C_TANEVID AND gondviselo.C_INTEZMENYID = telefon.C_INTEZMENYID
INNER JOIN T_TANULO tanulo ON tanulo.ID = gondviselo.C_TANULOID AND tanulo.C_ALTANEVID = gondviselo.C_TANEVID AND tanulo.C_ALINTEZMENYID = gondviselo.C_INTEZMENYID
WHERE telefon.C_FELHASZNALOID IS NULL

GO
ENABLE TRIGGER tr_telefonLog ON T_TELEFON