Solved

Multithreaded App with MSSQL

Posted on 2010-11-29
2
333 Views
Last Modified: 2012-05-10
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
Comment
Question by:DanJourno
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34232662
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
 
LVL 3

Expert Comment

by:manlimnag
ID: 34247241
if you want to doubly sure use the hints in query how to apply locks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question