You are here: Re: Problem when changing Views « MsSQL Server « IT news, forums, messages
Re: Problem when changing Views

Posted by Erland Sommarskog on 07/06/06 22:03

Jim Devenish (internet.shopping@foobox.com) writes:
> Thank you for your helpful advice. I had not appreciated that using
> Order By within a View was nonsense. I am in the process of converting
> the back-end of my database from Access to SQLServer and so am new to
> the latter. CustomerListQuery had been an Access query used as the
> RecordSource of a Form but in order to speed things up I made into a
> View.
>
> Are now suggesting that I remove Order By from the View and then make
> the RecordSource into:
> Select * From CustomerListQuery Order By AccountName

Yes.

> I have just looked at BOL for 'Order By' and find that it says:
> "The Order By clause is invalid in Views ... unless TOP is also
> specified"
> This implies that it can be used in this way but it does not say that
> it fails to carry out the ordering.

TOP 10 PERCENT ORDER BY is meaningful, because it picks the the top 10
percent according to the ORDER BY clause.

TOP 100 PERCENT ORDER BY is meaningless, because 100 percent is
everything, so it does not matter what you order by. You still get
everything.

That is, the purpose of ORDER BY in views in combination of TOP is to
determine which rows that are selected by the view.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация