Solved

Multithreaded App with MSSQL

Posted on 2010-11-29
2
307 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
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now