Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Index was not longer optimized
Message
 
 
To
06/04/2010 14:09:52
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01458951
Message ID:
01458998
Views:
25
>>I don't see an ORDER BY field in your example. ORDER BY 1 is no order - do you want them to be in the clustered index order?
>
>This is the SQL:
>
>
>DECLARE @NoMember Integer
>
>SET @NoMember=1
>
>SELECT Thread.Numero,Thread.Title,Thread.Url,Thread.AddDate
> FROM (SELECT TOP 10 Reply.NoThread FROM Reply (NOLOCK) WHERE Reply.NoMember=@NoMember ORDER BY 1 DESC) Temp
> INNER JOIN Thread ON Temp.NoThread=Thread.Numero 
>
>
>Basically, this is the one showing the last 10 replies in the Dashboard. So, ordering by 1, thus by Reply.NoThread, in DESC, would give the most recent ones as NoThread is the Thread.Numero reference, which is the primary key. Or, is it that ORDER BY 1 serves for no use in SQL Server and that I would have to use ORDER BY Reply.NoThread?

I think it works OK in SQL Server, but better to use field names. I got confused myself - thanks to Tracy for setting me straight.

BTW, out of curiosity, can you compare your query with mine and tell which one is faster?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform