bialain
Messages postés11Date d'inscriptionmardi 27 avril 2010StatutMembreDernière intervention23 mars 2011
-
12 sept. 2010 à 10:40
foliv57
Messages postés420Date d'inscriptionvendredi 17 novembre 2006StatutMembreDernière intervention15 juillet 2014
-
12 sept. 2010 à 23:25
Bonjour mes amis.
j'ai un problème de limiter les enregistrements et je veux qlq'un pour m'aider.
En effet, j'ai créé un procedurre stocké comme suit:
ALTER PROCEDURE [dbo].[Ps_OrientationSection]
@SectionAuto int
AS
insert into TabOrientation(EtabliOrigineAuto,EleveAuto,SectionAuto)
(select EtabliOrigineAuto,EleveAuto,Choix1 from View_choix_1 where Choix1= @SectionAuto and EleveAuto NOT IN (SELECT EleveAuto FROM TabOrientation))
Jusqu'ici, pas de problèmes. Mais quand je veux limiter les lignes en utilisant " Top ", il y a un message d'erreur qui s'affiche. voici comment j'ai fait:
ALTER PROCEDURE [dbo].[Ps_OrientationSection]
@NTop int,
@SectionAuto int
AS
insert into TabOrientation(EtabliOrigineAuto,EleveAuto,SectionAuto)
(select top @NTop EtabliOrigineAuto,EleveAuto,Choix1 from View_choix_1 where Choix1 =@SectionAuto and EleveAuto NOT IN (SELECT EleveAuto FROM TabOrientation))
Le message d'erreur est :
Msg 102, Level 15, State 1, Procedure Ps_OrientationSection, Line 18
Incorrect syntax near '@NTop'.
Msg 102, Level 15, State 1, Procedure Ps_OrientationSection, Line 18
Incorrect syntax near ')'.
Où est que je me suis trompé? J'utilise le SqlServer.
foliv57
Messages postés420Date d'inscriptionvendredi 17 novembre 2006StatutMembreDernière intervention15 juillet 20149 12 sept. 2010 à 23:25
Pardon, j'ai répondu trop vite, il vous manque juste les parenthèses :
insert into TabOrientation(EtabliOrigineAuto,EleveAuto,SectionAuto)
(
select top(@NTop) EtabliOrigineAuto,EleveAuto,Choix1
from View_choix_1
where Choix1=@SectionAuto
and EleveAuto NOT IN (SELECT EleveAuto FROM TabOrientation))