Prevent a Stored Procedure from being executed twice at the same time

后端 未结 5 820
甜味超标
甜味超标 2021-01-02 17:10

I have a stored procedure for SQL Server 2000 that can only have a single instance being executed at any given moment. Is there any way to check and ensure that the procedur

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-02 17:35

    You can use sp_getapplock sp_releaseapplock as in the example found at Lock a Stored Procedure for Single Use Only.

    But, is that what you are really trying to do? Are you trying to get a transaction with a high isolation level? You would also likely be much better off handling that type of concurrency at the application level as in general higher level languages have much better primitives for that sort of thing.

提交回复
热议问题