View Single Post

   
  #6 (permalink)  
Old 02-29-2008, 07:51 AM
Gert-Jan Strik
 
Posts: n/a
Default Re: top keyword and sorting

Run the example below, and it is easy to see that the result is not
sorted.

create table #t (col1 varchar(20))
insert into #t values ('a')
insert into #t values ('z')
insert into #t values ('b')
insert into #t values ('y')
insert into #t values ('c')
insert into #t values ('x')

select top 3 * from #t

drop table #t

col1
--------------------
a
z
b

(3 row(s) affected)

Gert-Jan

paulshealy1@gmail.com wrote:
>
> I heard a claim recently at a SQL Server users group meeting that the
> TOP keyword forces sorting on a database server. I can't find any
> reason this might be true and the Books Online say nothing about it.
> Can someone verify this claim one way or the other?

Reply With Quote