est ici le script:Erreur lors de la création d'un script SQL
create procedure sp_DescuentoAlquiler
as
declare @IDAlquiler int, @NumeroPelicula int, @MontoTotal float
declare cursorAlquiler cursor for
select a.ID, count(d.ID) as @NumeroPelicula
from Alquiler a inner join DetalleAlquiler d on a.ID = d.IDAlquiler
group by a.ID
open cursorAlquiler
fetch next from cursorAlquiler into @IDAlquiler, @NumeroPelicula
while @@FETCH_STATUS = 0
begin
if(@NumeroPelicula >= 3)
begin
select @MontoTotal = SUM(d.PrecioAlquiler)
from DetalleAlquiler d where d.IDAlquiler = @IDAlquiler
update Alquiler set MontoTotal = @MontoTotal * 0.3
where ID = @IDAlquiler
end
fetch next from cursorAlquiler into @IDAlquiler, @NumeroPelicula
end
close cursorAlquiler
deallocate cursorAlquiler
Je reçois une erreur dans la ligne 6 après comptage (d.ID), sur @NumeroPelicula:
Msg 102, Niveau 15, état 1, procédure sp_DescuentoAlquiler, ligne 6 Incorrect syntaxe près de '@NumeroPelicula'.
Des suggestions?
Ceci est bien sûr quelque chose qui ne devrait pas être fait dans un curseur. – HLGEM