Select paginé

Résolu
thiosyiasar Messages postés 186 Date d'inscription lundi 11 mars 2002 Statut Membre Dernière intervention 30 novembre 2010 - 9 janv. 2007 à 14:41
thiosyiasar Messages postés 186 Date d'inscription lundi 11 mars 2002 Statut Membre Dernière intervention 30 novembre 2010 - 9 janv. 2007 à 15:21
Bonjour a tous,

Pour une page aspx, je voudrais faire un select paginé du genre :
 
SELECT TOP (@nb_ligne) * FROM newsletter WHERE nlt_id in
(
  SELECT nlt_id FROM newsletter WHERE nlt_id not in
  (
    SELECT TOP (@index_ligne) nlt_id FROM newsletter
  )
)

On ne peut apparement pas utiliser de variable avec le mot clé TOP sur SQLServer 2000
Alors qu'avec 2005, apparement si -->  http://msdn2.microsoft.com/en-us/library/ms189463.aspx

Quelqu'un a une solution sur SQLServer 2000 ?

Nico

2 réponses

cs_skweeky Messages postés 259 Date d'inscription mercredi 3 mai 2006 Statut Membre Dernière intervention 11 janvier 2010 8
9 janv. 2007 à 15:03
Bonjour,

Via un SQL dynamique

EXEC ('
SELECT TOP (' + CAST(@nb_ligne as varchar(10)) + ') * FROM newsletter WHERE nlt_id in
(
  SELECT nlt_id FROM newsletter WHERE nlt_id not in
  (
    SELECT TOP (@index_ligne) nlt_id FROM newsletter
  )
)')

(désolé pour le manque de color coding :o(

Cordialement

Christian Robert - Winwise
http://blogs.codes-sources.com/christian/
MVP SQL S
3
thiosyiasar Messages postés 186 Date d'inscription lundi 11 mars 2002 Statut Membre Dernière intervention 30 novembre 2010 3
9 janv. 2007 à 15:21
Effectivement

Merci pour ton aide

Nico
0
Rejoignez-nous