470,594 Members | 1,381 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

insert command sql server 2005


I do this - take some data with sqldataadaptor (at this moment
2000rows) in fill datatable.

For each two rows do some calculations and save data to the database
with insert command.
(the data which I insert are 5 int values for each two rows - so
2000*1999 insert commands)
In this way it is very slow. I think this is because of the invoking so
many times of the insert command (because without insert command it
takes about 10 min, but with it may be it will work 1-2 days (I run the
program in debug mode)).

Do you know other ways to do this (faster)?
(may be with sqldataadaptor).


Nov 3 '06 #1
1 3561
So each crossed combination (except to self) needs a row? In this scenario,
I would probably find a way of saving the 2000 rows into a staging table on
the sql-server (2000 inserts), and then running an SP (or other SQL command)
that does the cross join and calculations locally to save round trips. Of
course, first I would verify the need for the cross-join at all, as this is
(obviously) not linearly scalable.

Another option (for more complex calculations) would be to do the cross-join
in the C# (as now), but write the data as csv / tsv to a text file, then
bulk insert the text file. Less round trips, but still transfers more data
over the network.

Nov 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dot Net Daddy | last post: by
7 posts views Thread by anu b | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.