попробуйте это:
CREATE TRIGGER ATTENDANCE_INSERTION_TRIGGER
ON course_enrollment
AFTER INSERT
AS
BEGIN
--insert **what just was inserted in course_enrollment** into
-- course_schedule_attendance
INSERT course_schedule_attendance
(course_id, student_id)
SELECT
course_id, student_id --you could use: INSERTED.course, INSERTED.student_id
FROM INSERTED
END
GO
Вы также можете сделать это в одной вставке, без триггера:
--insert a single row in both tables at one time
INSERT course_enrollment
(course_id, student_id)
OUTPUT course_id, student_id INTO course_schedule_attendance
VALUES (@xyz, @abc)
--or insert a set of rows into both at one time
INSERT course_enrollment
(course_id, student_id)
OUTPUT course_id, student_id INTO course_schedule_attendance
SELECT
xyz, abc
FROM ...