I have a search function set up, where I run multiple queries simultaneously. The top 1000 results of each query are written to a table. (These run async–I am just leaving out the code that I am using to do that)
Insert into Results
Select Top 1000 Text from A where Contains(Text,'"searchString"')
Insert into Results
Select Top 1000 Text from B where Contains(Text,'"searchString"')
Insert into Results
Select Top 1000 Text from C where Contains(Text,'"searchString"')
Then, I select the top 1000 results from that table.
Select Top 1000 * from Results
Would there be a good way to efficiently check, at any point earlier in the process, if there are already 1000 results, and, if there are, cancelling the other queries and selecting the 1000 results ASAP.
The following will likely give you a plan that achieves your desired result of not processing any rows after the 1,000th one has been found.