Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Multithreaded App with MSSQL

Hi,

I've got a multitheaded application using MSSQL.
This question has been simplified to avoid confusion.

If I program 10 threads to do the following 10,000 times:-

UPDATE tblTest SET fCounter=fCounter+1

..can I be sure that fCounter will always equal 100,000 at the end even though its getting the command hundreds of times per second?

Is there a setting I need to change that will force SQL server to keep track of things properly?
Thanks
Dan
0
DanJourno
Asked:
DanJourno
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
It should do because SQL will lock the row for each update. Therefore SQL should allow more than one connection to perform the update at once.
0
 
manlimnagCommented:
if you want to doubly sure use the hints in query how to apply locks
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now