Solved

Multithreaded App with MSSQL

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql help 8 55
VB.NET (2008) - Refactoring Question 2 19
VB.NET 1 21
SQL Server Count where two id types exist in column 8 27
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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