1

I need to insert all the rows in a gridview into a SQL Server 2005 database at once.

Number of rows can be 1 to n (not more than 200)

I have investigated the following options:

  • Loops: I want to avoid the iterations.
  • Table datatype: available in SQL Server 2008 and onwards only
  • Bulk Copy: useful in case of bulk data. I am not sure whether I can use it insert less no of rows (performance wise)

What else I can use?

2
  • first try to solve the solution, then think about other alternatives, based on performance. or set up counters to measure the performance.
    – Ravi Gadag
    Aug 28, 2012 at 10:10
  • If you're stuck on 2005 and cannot update to 2008, and you want to avoid the "iterations" - bulk copy seems to be about the only way to go
    – marc_s
    Aug 28, 2012 at 10:12

1 Answer 1

0

Try to use a set-based approach opposed to loops/cursors. Loops and cursors will become less efficient with a larger amount of data, but for relatively small amounts it should be fine.

http://www.codeproject.com/Articles/34142/Understanding-Set-based-and-Procedural-approaches

That link should give you a bit of a heads up on how to approach a set-based approach.

Hope this is what you're looking for!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.