Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Index was not longer optimized
Message
 
 
À
06/04/2010 14:09:52
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01458951
Message ID:
01458998
Vues:
26
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform