Thursday, 2 July 2015

To handle Dead Lock on Table


Create PROCEDURE [dbo].[CreateSp_toHandleDeadLockonTable]
AS
BEGIN
   
BeginHistory:
BEGIN TRY
                       --Add your code here
END TRY

BEGIN CATCH
  IF @@TRANCOUNT > 0 ROLLBACK TRAN

 IF ERROR_NUMBER() = 1205 --DEADLOCK
  BEGIN
   WAITFOR DELAY '00:00.051'
   GOTO BeginHistory
  END
 ELSE
  BEGIN

  END
 END CATCH
END

No comments:

Post a Comment