SQLTeam.com | Weblogs | Forums

Select from Multiple Tables and Insert into one table


#1

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?


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