Inconsistent Results when Executing Statements in a Loop
SQL Operations Studio Version:
- 0.23.6 (0.23.6)
Background: I often find myself writing scripts to perform a series of tasks against a list of entities, for example, calling a sproc n times where n = a list of ids I need to work with.
I've always preferred to perform these tasks using a simple loop instead of a cursor.
In SQL Operations Studio, I see inconsistent results of executing this looping logic - it seems the first one or two iterations function as I'd expect, but after that I don't see the results I would traditionally see if I executed the script using SSMS.
Steps to Reproduce: I've attached a small sample script that should reproduce the behavior.
What I Would Expect to See from the attached Script
- I would expect my loop to execute 10 times, and I would expect to see 10 result sets, each outputting the text "Working With {N}" where {N} is replaced by the record ID of the processed record.
What I see Instead:
- I see the loop execute 10 times, but the result sets are inconsistent. I see 1 to 3 actual results sets where the expected text is returned. The other expected result-sets have no returned data.
In SSMS:
- The same script executes and behaves as expected.
I was unable to reproduce this bug with the script you provided (also on 0.23.6). I did notice, however, that there is a noticeable delay on the result sets data (the header loads immediately) when scrolling. If I scroll quickly and then stop, then the results show after a brief delay, even if I have already viewed them.
@arinwt That's really odd! I ran this multiple times before submitting this issue, and each time I paused as I scrolled through the list of results and never saw anything show up past the first 3! I just re-ran the script and now it works as you describe.
For what it's worth, the "actual" script I observed this in I was calling into a sproc multiple times with different sets of parameters and saw only the first few executions return data. I expected results, so ran the process in SSMS and immediately saw the results I was looking for. Went back to SQL OPS and saw the reported behavior, so I created a simple script to illustrate what I was seeing.
@tlentine I wasn't able to repro this on the latest build with the attached script. I saw similar to @arinwt where there is a small delay to render the result sets when scrolling.
That said, we do have other active bugs related to failed rendering with lots of resultsets, so perhaps we may fix the underlying issue here when we resolve those. Please reactive if you're still hitting this issue. Thanks!