Sunday, March 11, 2012

Bug in SELECT TOP (100) PERCENT with ORDER BY in SQLExpress?

I have a problem with the following query in SQLExpress:

SELECT TOP (100) PERCENT ClientSurname, ClientName
FROM dbo.Client
ORDER BY ClientSurname, ClientName

The query returns always assorted data ignoring the ORDER BY keyword, no matter if the query is invoked directly from Management Studio Express CTP as a View, Table-valued function or called from an Access ADP project. The result is always assorted.

Now an interesting thing is that the syntax below returns always an expected order:

SELECT TOP (99) PERCENT
SELECT TOP 10000

Am I missing something or is it a bug in SQLExpress?I never use the brackets (parenthesis) around the percentage. Maybe your second example is just using the top 10000 (not the 99%) and sorting your recs as you expect.

Keeping in mind that I know nothing of this SQLExpress :)|||TOP is a function, not a predicate as it used to be in 2K.

No comments:

Post a Comment