SQLTeam.com | Weblogs | Forums

Select from Multiple Tables and Insert into one table


I have multiple tables A, B, C. All three tables have a field called ID.
I have a fourth table D.
I have a stored procedure that will select ID from each of the three tables A, B, and C separately and insert the values of ID into table D.
I want one stored procedure that when ran it selects ID from each of tables A, B, and C and Inserts the data into table D in one fell swoop.

Anyone know how to do this?

insert into D(ID)
select ID from A
union all
select ID from B
union all
select ID from C