Doit déclarer la variable scalaire "@bit", dans la procédure stockée comme paramètre de sortie

J'ai cette procédure, mais quand cela fonctionne parfaitement, sans les deux if qui définissent le paramètre de sortie @bit. Lorsque j'essaie d'exécuter proc p3, l'erreur suivante se produit

Must declare the scalar variable "@bit".

Voici le code

 create proc p3 @codP int, @codM int, @dela datetime, @panala datetime, @pret smallint, @bit bit output as begin declare @val smallint set @val = (select COUNT(*) from OferteSpeciale as OS where OS.codP = @codP and OS.codM = @codM and ((@panala >= OS.dela and @panala <= OS.panala) or (@dela >= OS.dela and @dela <= OS.panala) or (@dela <= OS.dela and @panala >= OS.panala))) print @val if (@val = 0) begin insert into OferteSpeciale (codP,codM,dela,panala,pret) values (@codP,@codM,@dela,@panala,@pret) declare @others smallint set @others = (select COUNT(*) from Cataloage as c, OferteSpeciale as os where ((c.codM = @codM and c.codP = @codP and c.pret < @pret) or (os.codM = @codM and os.codP = @codP and os.pret < @pret))) if (@others > 0) set @bit = 0 else set @bit = 1 end else RAISERROR 50001 'There is already a special offer for that product, in that shop, between that dates' end declare @bit bit exec p3 1, 3, '2013-04-15', '2013-04-15', 25, @bit output 

Juste comme une réponse rapide, il vous manque un "GO" après avoir déclaré votre proc stocké, si j'essaye de l'exécuter comme je l'ai prévu, j'obtiens une erreur différente qui disparaît si j'ajoute un GO pour séparer la déclaration de l'exécution.

 end GO declare @bit bit exec p3 1, 3, '2013-04-15', '2013-04-15', 25, @bit output 

Évidemment j'ai dû enlever le contenu du proc stocké car je n'ai pas ces objects dans ma DB, mais le problème semble être autour de "@Bit"