Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.sqlserver.programming
Select top .... order by
Ressiv Kire
3/24/2007 8:27:00 AM
Hi,
OK, learned the hard way not to use SELECT TOP 100 PERCRENT ...
but are there any disadvantages in changing the views where this is used
into
SELECT TOP 999999999999999999 ....
Erik
2 Answers
Tibor Karaszi
3/24/2007 8:48:00 AM
0
It still only guarantees the correct rows. It won't guarantee the order of the rows (even if the
execution plan might often give you that).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/d...
http://sqlblog.com/blogs/tib...
"Ressiv Kire" <ressiv.kire@gliw.ln> wrote in message news:ul2Zs4ebHHA.1508@TK2MSFTNGP06.phx.gbl...
> Hi,
>
> OK, learned the hard way not to use SELECT TOP 100 PERCRENT ...
> but are there any disadvantages in changing the views where this is used into
> SELECT TOP 999999999999999999 ....
>
> Erik
>
David Portas
3/24/2007 10:28:00 AM
0
On 24 Mar, 08:26, "Ressiv Kire" <ressiv.k...@gliw.ln> wrote:
> Hi,
>
> OK, learned the hard way not to use SELECT TOP 100 PERCRENT ...
> but are there any disadvantages in changing the views where this is used
> into
> SELECT TOP 999999999999999999 ....
>
> Erik
Yes there are disadvantages. TOP x in a view achieves nothing useful
other than limit the view to x number of rows. Queries against the
view will still return an undefined ordering unless you specify ORDER
BY in those queries.
So I suggest you simplify the view by removing TOP and ORDER BY
altogether.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/librar...
(en-US,SQL.90).aspx
--
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Select top .... order by
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password