I tried SQL lock with stored procedure to prevent multiple execution of same stored procedure at a same time. but it seems it is not preventing. Below syntax will create getlock and run the same transaction five time. but all the 5 time it is achieving the lock. I might be wrong somewhere but i have tried same with my stored procedure but over there also same issue is happening.
BEGIN TRANSACTION
DECLARE @LockId INT
Exec @LockId =sp_getapplock @Resource='ABC', @LockMode='Exclusive', @LockOwner='Transaction', @LockTimeout = 10
IF(@LockId<0)
BEGIN
PRINT 'LOCK FAILED'
ROLLBACK TRANSACTION
RETURN
END
PRINT 'LOCK SUCCEED'
COMMIT TRANSACTION
GO 5