Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How does sql server order results if a query returns multiple.?

0
10 Posted

How does sql server order results if a query returns multiple.?

0
10

There is no particular order in which the sql query returns a result set. If the result contains multiple elements like what you have specified (9377 9372 9374), The sql query can return the same result set in whatever order it pleases. In most cases, queries which occur in near time frame (say less than 1 minute), the result set does not change and the order is retained. If you restart the sql server or export the data to another DB, you may experience different orders. You can conquer this by using a “order by” clause. Select * from employee order by EMP_NAME; This will always bring up the same order and is much faster too on the long run. Once you query using order by clause, the cache mechanism works in such a way as to insert data in a sorted order.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123