Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 advice for multiple inserts

Author  Topic 

gobotsoup
Starting Member

6 Posts

Posted - 2007-04-11 : 14:02:56
hi I was just writing for some general advice. If I am to do many updates on a table is it okay to keep updating with many insert statements inside of a loop closing the connection each time? Here is some pseudo code to give you an idea:

cnn.open();
cmd = "insert into Cats values (red,4994,homer)";
for(int i=0; i<10000; i++)
{
cmd.executenonquery();
cnn.close();
}

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-11 : 14:15:38
I would keep the connection open until you are done with the loop.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2007-04-14 : 16:44:27
Why not run it in a SP your script could timeout.
Go to Top of Page
   

- Advertisement -