1

When I execute a TSQL query or a stored procedure that returns large number of records (1M+) by default it begins to display result while query is still executing.

Is there way to prevent this and postpone returning of the result until the query execution is complete?

2
  • 1
    Why would you want this? It is possible by storing in a #temp table or maybe rewriting the query to get a blocking operator but it then takes server memory storing the whole result set. Commented Aug 27, 2013 at 17:18
  • I think this might be causing issue in my other question: stackoverflow.com/questions/18468284/… (maybe I am wrong but it seems .NET code reads only "Fast N" results) Commented Aug 27, 2013 at 17:26

2 Answers 2

1

If you add a column like the following to the returned dataset, it almost certainly will not be able to do a FAST(N):

.., MAX(prevColumn) OVER(PARTITON BY 1) As Dummy, ...

Where prevColumn is any other column that you are already returning, especially if it's not an indexed column.

Sign up to request clarification or add additional context in comments.

1 Comment

That did it, thanks. Though turned out wasn't needed for my other problem :) but thanks anyway
0

You can use ORDER BY or Aggregate function in SELECT will help you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.