If the use of the procedures applicable to your application you might use the MERGE statement to combine your data.
To learn more about merging follow http://msdn.microsoft.com/en-us/library/bb510625.aspx topic
Added OUTPUT usage sample, it shows how to get inserted row's PK to insert in other related table.
CREATE TABLE #teachers(
[ID] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](15) NOT NULL
)
CREATE TABLE #pupils(
[ID] [int] IDENTITY(1,1) NOT NULL,
[name] [nvarchar](15) NOT NULL
)
CREATE TABLE #createdTeachers ([ID] [int])
CREATE TABLE #createdPupils ([ID] [int])
insert into #teachers output inserted.ID into #createdTeachers values ('teacher#2')
insert into #teachers output inserted.ID into #createdTeachers values ('teacher#1')
insert into #pupils output inserted.ID into #createdPupils values ('pupil#2')
insert into #pupils output inserted.ID into #createdPupils values ('pupil#1')
select t.ID as NEW_TEACHER_ID,p.ID as NEW_PUPIL_ID from #createdTeachers as t , #createdPupils as p
I did not prepare sample, which describes your diagram fully but necessary concepts are shown.
You might use "select t.ID as NEW_TEACHER_ID,p.ID as NEW_PUPIL_ID from #createdTeachers as t , #createdPupils as p" to insert teacherId, pupilId etc into Teacher_Pupil table