SQLTeam.com | Weblogs | Forums

Loop

I have the list of 10, 20, 30, ect and need to pass this ID into the table below to get the table name and then insert
the values into temp table. I think we can do a loop but i am not sure how to start with, can you please help?

(10 for saleoder10, 20 for saleoder20, 30 for saleoder30, ect)

Create procedure dbo.getorder
As
begin
insert into temp (oder, sale)
select order, sale
from saleoder10
end