Procédure stockée

Fermé
bialain - 12 sept. 2010 à 10:56
Bonjour,

j'ai un problème de limiter les enregistrements et je veux qlq'un pour m'aider.
En effet, j'ai créé un procédure stockée 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.

Je vous remercie