If in your stored procedure you defined a cursor, it is sometimes easy to forget to close it.
Below are examples on how to ensure cursors are closed:
BEGIN TRAN
DECLARE @CurrentId int
DECLARE @IdCursor CURSOR
SET @IdCursor = CURSOR FOR SELECT Id FROM MyTable
OPEN @IdCursor
FETCH NEXT FROM @IdCursor INTO @CurrentId
WHILE (@@FETCH_STATUS) = 0
BEGIN
IF @@error <> 0 GOTO err
FETCH NEXT FROM @IdCursor INTO @CurrentId
END
CLOSE @IdCursor
DEALLOCATE @IdCursor
COMMIT TRAN
RETURN 0
err:
ROLLBACK TRAN
DECLARE @CursorStatus int
SET @CursorStatus = CURSOR_STATUS('variable','@IdCursor')
IF (@CursorStatus) > 0
CLOSE @IdCursor
IF (@CursorStatus <> -2)
DEALLOCATE @IdCursor
RETURN 1