Home > Ask the SQL Server Experts > Mark Kromer - SQL Server Business Intelligence Questions & Answers > Ordering the results of a SQL query
Ask The SQL Server Expert: Questions & Answers
EMAIL THIS

Ordering the results of a SQL query

Mark Kromer EXPERT RESPONSE FROM: Mark Kromer

Pose a Question
Other SQL Server Categories
Meet all SQL Server Experts
Become an Expert for this site


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 03 September 2008
I am using a case statement to order data on a SQL Server Reporting Services report. When the statement runs it returns the correct order, but when I save the Report Definition Language (RDL) and preview it, it returns to ascending order. How do I correct this?

>
EXPERT RESPONSE
It is a little hard to verify this without seeing the code. However, the typical rule of thumb is that if you do not explicitly order the results in a SQL query, then you are at the mercy of the database or API engine that is producing the results. Try explicitly adding an ORDER BY to your statement.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
SQL/Transact SQL (T-SQL)
Avoid cursors in SQL Server with these methods to loop over records
Implementing security audit in SQL Server 2008
New datetime data types in SQL Server 2008 offer flexibility
Basic objects of T-SQL in SQL Server 2008
Using T-SQL data types in SQL Server 2008
SQL Server 2008 function types in T-SQL
Additional T-SQL operations in SQL Server 2008
Using DATEADD and DATEDIFF to calculate SQL Server datetime values
Manipulate column names in a SQL Server table
SQL Server trigger vs. stored procedure to receive data notification
SQL/Transact SQL (T-SQL) Research

SQL Server data warehousing/business intelligence
Tutorial: SQL Server Integration Services (SSIS) best practices
FAQ: Troubleshooting SQL Server Reporting Services
What's new in SQL Server 2008 Reporting Services?
SQL Server 2008 Integration Services delivers new features
Tips for tuning SQL Server 2005 to improve reporting performance
Parent-child dimensions in SQL Server 2005 with Analysis Services MDX
Troubleshoot Web service issues in SQL Server 2005 Reporting Services
SSIS error message due to installation problem on SQL Server 2005
Configuring SQL Server with a changed computer name
Using MDX and UDM in a SQL Server Analysis Services environment

SQL Server performance and tuning
How to configure storage in SQL Server DB with more writes than reads
Avoid cursors in SQL Server with these methods to loop over records
Solve SQL Server errors and more from the DBA trenches -- part 2
Tutorial: Learn SQL Server basics from A-Z
FAQ: Troubleshooting SQL Server Reporting Services
How to disable the shrink database task in SQL Server 2000 and 2005
SQL Server out of memory: Troubleshoot and avoid SQL memory problems
Basic objects of T-SQL in SQL Server 2008
Using T-SQL data types in SQL Server 2008
Additional T-SQL operations in SQL Server 2008

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
ACID  (SearchSQLServer.com)
commit  (SearchSQLServer.com)
DAO  (SearchSQLServer.com)
fetch  (SearchSQLServer.com)
OLE DB  (SearchSQLServer.com)
query  (SearchSQLServer.com)
SQL  (SearchSQLServer.com)
T-SQL  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



SQL Solutions - SQL Database Design
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2005 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts