Skip to content Skip to sidebar Skip to footer

How To Hint Update Lock Without Duplicating Stored Procedure Code

I've an existing stored procedure SP1 which is simple select from a table. It's being used at multiple places. Now there is a new code which uses this SP1 along with an update sta

Solution 1:

If the calls to SP1 follows by SP2 are atomic, they should be combined in T-SQL. Or lose the c# transaction. You are prolonging the transaction unnecessarily with roundtrips.

Also, why have UPDLOCK on SP1UPDLOCK but not for SP1? I can't see why. If the problem is lock hints, don't use them. If something is serializable (why?) then again, make it a single atomic call

Note that the default is READ COMMITTED anyway

Finally, do you mean "semaphore" not lock? Using sp_getapplock will control flow through the code without using locks on the data

Post a Comment for "How To Hint Update Lock Without Duplicating Stored Procedure Code"