inserting bulk record from db to db

dec21st

Active member
Joined
May 14, 2005
Messages
43
Programming Experience
3-5
say i want to extract a few rows from table 1 and insert it into table 2... how do i do it??

one method is to create an sql reader to extract data from table 1 then use stored proc to insert into table 2

i'm thinking of the performance whether will it lag when i execute the command

one method i use last time with vb is that i create 2 recordset then just insert data from one recordset to another...

what's the best way i can do it using vb.net??? btw i'm using msde (sql server) as my db
 
This might work. Try using datasets. You can use them to store data and then I'm pretty sure you can just fill your tab;e 2 with the dataset
 
done it! works flawlessly

VB.NET:
CREATE PROCEDURE Proc_settleBill
(
 @tableID int,
 @dateNow dateTime,
 @waiterID int,
 @discountType int,
 @subtotal money,
 @total  money,
 @cash  money
)
AS
 
INSERT INTO totalSales (invNo, dateTime, waiterNo, discountType, subtotal, 
 
total, cash) values (@tableID, @dateNow, @waiterID, @discountType, 
 
@subtotal, @total, @cash)
 
INSERT INTO sales (invNo, itemNo, qty)
SELECT
tempSalesID, itemNo, qty
FROM
tempSales
WHERE
tempSalesID = @tableID
 
DELETE FROM tempSales WHERE tempSalesID = @tableID
DELETE FROM tempTable WHERE tempTableID = @tableID
 
GO
 
Back
Top