Home Forums SQL Server 2005 T-SQL (SS2K5) Using ORDER BY in a query returns more rows than if ORDER BY is not used RE: Using ORDER BY in a query returns more rows than if ORDER BY is not used

  • Along with Luis and Ed I can't find anything obvious in your query that would cause there to be different rows to be returned based on the addition of an ORDER BY clause because ORDER BY shouldn't ever affect the number of rows returned.

    I'd suggest the following:

    1. Capture and post the execution plans for the query both with and without the ORDER BY. Seeing what the optimizer is doing may be helpful.

    2. Just run the SELECT without the 2nd table using the same criteria with and without the ORDER BY to see what happens.

    3. Run the query without all the UDF's in the SELECT and see what happens.