Different limit behavior when executing script versus executing a statement
- Dominant language
- Java
- Stars
- 51.8k
- Forks
- 4.4k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 188
Description
This issue/feature relates to the automatic limits put on queries once they are being run as a statement.
The limits are not added on multi-queries scripts, like when you execute three selects in one script at once.
**Example**
In case I run the "Execute statement", we see this behavior.
`select * from RefillAttempt order by ID desc`
That underlying (somehow) transforms to this.
`select top 50 * from RefillAttempt order by ID desc`
While if we run "Execute script", we see this behavior
```
select * from RefillAttempt order by ID desc
select * from OrderLine order by ID desc
select * from Subscription order by ID DESC
```
Whom does **not** transform to this.
```
select top 50 * from RefillAttempt order by ID desc
select top 50 * from OrderLine order by ID desc
select top 50 * from Subscription order by ID DESC
```
The effect is three very slow results sets, whom at first puzzled me.
Adding the limits to each query quickly confirmed my suspicion, the auto limit is not applied.
**What I expected**
I regard all the execution options the same, so I would have expected the same effect when running a script.
With the limits being placed on each query, for each result set.
**My only other alternative as of now**
Turn off auto limits, as expecting not to make the same mistake again is highly unlikely.
Better to control everything when the limits only "sometimes" apply. :)
**Behavior**
To add more information, I often just get a never ending result set if I don't put the limits myself.
Usually ending up in cancelling the job or invalidating my connection to force it off, a bit wonky.
Contributor guide
Assessment
This issue has not been assessed yet.