Home Forums SQL Server 7,2000 T-SQL How to Single-Thread a stored procedure RE: How to Single-Thread a stored procedure

  • Excellent information. Minor point, according to Microsoft's documentation on sp_getapplock the error trap code should actually be as follows:

    IF @Result < 0

    BEGIN

    ROLLBACK TRAN

    RAISERROR('Procedure Already Running - Concurrent execution is not supported.',16,9)

    RETURN(1)

    END

    sp_getapplock will return 0 if it locks immediately and 1 if it locks after waiting for other locks to clear. All failures will be negative values.

    http://technet.microsoft.com/en-us/library/aa933410(v=sql.80).aspx