Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Make SQL Server Respond to an ORDER BY Clause : Page 4

SQL Server Views don't support the ORDER BY clause, but that shouldn't stop you from bringing order to your data. This article teaches you how to sort the results of a View, despite this small limitation.


advertisement
There's one problem with the TOP 100 PERCENT solution. As is, the View could drop a record from the results. When the last value has two or more records with the same value, the View includes only one. To avoid this problem, add the WITH TIES clause to the TOP statement in the form:

SELECT TOP 100 PERCENT WITH TIES

Circumvent the Rules
Rules are made to be broken. SQL Server doesn't support the ORDER BY clause in a View, but you've seen how to get around that limitation by adding a TOP 100 PERCENT clause to the View. When you do, SQL Server interprets and correctly responds to an ORDER BY clause.




Susan Sales Harkins (harkins@iglou.com) is an independent consultant who writes for a number of publishers. She specializes in Access. "SQL: Access to SQL Server", her latest book, was released in January 2002.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date