techmad
techmad

Reputation: 933

SQL Server Database Update using Multithreading

I have a requirement to update 20 tables in a SQL Server database in a C# application. For better performance, I am planning to use multiple threads for updating tables. Could anybody refer any example link which gives idea for this kind of operation?

Also, as per my understanding, if I use multi threading, then I have to use different connection object for each thread. In that case, how I can put multiple threads in a single transaction, which are basically using different connection objects?

Upvotes: 3

Views: 2164

Answers (2)

safeer ahmad
safeer ahmad

Reputation: 25

Use TPL (task parallel library), here is an example http://safeery2k.wordpress.com/2013/09/17/ado-net-using-tpl/

Upvotes: 1

Andrew Mack
Andrew Mack

Reputation: 312

20 tables to update at once is pretty crazy.

If 20 stored procedures is the ONLY way to do what needs to get done then create one more stored procedure that will call the 20 stored procedures for you and simply use this stored procedure.

This way if an error/exception occurs you will be able to rollback the mods AND it is now contained in one location - nice and easy (all things considered).

I'm very glad I don't have to deal with the situation you're in with this one! Good luck with this!

Upvotes: 0

Related Questions