Click here to Skip to main content
16,019,182 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a form before final save into database .
i need to insert multiple rows in to Temp table then i have to move to final table in final save .
by that performance of my web application is getting slow for every insert my appication is going to server and again grid is binding .
how can i avoid this time any fast saving method or any way to avoid temp table saving.


inserting mutiple rows means Example
a journel Voucher 1st 10rs tea one entry, 2nd 50 Rs sancks 3rd 500Rs for maintance charges.
i need to save all these thre entries under single voucher No.
so am inserting into temp table then finanlly saving into transation table.

thanks
karthik
Posted
Updated 16-Sep-11 18:25pm
v2
Comments
Tejas Vaishnav 17-Sep-11 6:20am    
If you like my ans then rate it...

Why insert multiple rows to a temp table - a single insert can have do more than one row. The best might be to use UNION ALL: http://blog.sqlauthority.com/2007/06/08/sql-server-insert-multiple-records-using-one-insert-statement-use-of-union-all/[^] and do it to your main table directly.
 
Share this answer
 
Comments
karthikkushala 17-Sep-11 0:19am    
sorry you understood wrongly ,
inserting mutiple rows means Example
a journel Voucher 1st 10rs tea one entry, 2nd 50 Rs sancks 3rd 500Rs for maintance charges.

i need to save all these thre entries under single voucher No.
so am inserting into temp table then finanlly saving into transation table.
OriginalGriff 17-Sep-11 3:50am    
So you want to make sure that all three insert, or all three fail?
So use a Transaction instead. Begin Trans at the start, Commit at the end. No changes go to the live DB until you Commit - any failure, and you Rollback instead.
Try this..

1) If Windows Application then
Declare a static ado.net data table that will hold your data while you fire your insert query it will directly inserted in that table other then of the sqlservers table..

then when you want to finalize your transactions at that time you have to call the insert query of sqlserver to insert data from that static data table to database table.

2) If Web application then

create a data table as describe as above, then create a session that will hold that table for you..
at the end you need to insert that records from that session data table to your db.

Benefit of using Data Table/Data set
1) its a in memory representation so it is faster then database table
2) you can perform all operation like database table will perform
3) faster response
 
Share this answer
 
Good way to remove temp tables is use complex queries by combing multiple table or use views...

even you can create a DataTable in your webpage so that travelsal from Web Page to Database is reduced.............
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900