Okay so I have this temp table. It has all the orders which a company needs to ship out. I need to somehow loop through the table and insert the information into 3+ tables.
@TempTable Table
(
OrderID Int
)
Declare @value int = (select count(orderID) from @temptable)
Declare @i int = 1
WHILE @i < @value BEGIN
Declare @orderid= (select first(orderid) from @temptable)
INSERT INTO shipment (orderid, Price, Date, DateDue)
VALUES (@orderid, @Price, @Date, @DateDue);
Set @i += 1
Delete top(1) from @temptable
END
Is there a better way of doing this?
Adding a little more to my issue
I'm taking in 3 values from VB.Net that as an example is @Price, @Date, and @DateDue.Because of this I wasn't able just to do a select statement cause the values are mixed with this passed values.