BEGIN TRANSACTION;

BEGIN TRY

INSERT INTO TESISSEG.dbo.AS_ILT_Profesiones (ILTP_Profesion, ILTG_Grupo, EmpID, OldID)
SELECT 
    p.ILTP_Profesion, 
    p.ILTG_Grupo, 
    c.EmpID,
    p.OldID
FROM AS_ILT_Profesiones p
JOIN Corredurias c
    ON p.EmpID = 1
LEFT JOIN AS_ILT_Profesiones aip 
    ON aip.EmpID = c.EmpID
WHERE aip.EmpID IS NULL;

    COMMIT TRANSACTION;
END TRY
BEGIN CATCH
    ROLLBACK TRANSACTION;
    PRINT 'Error: ' + ERROR_MESSAGE();
END CATCH;