-- 创建存储过程 CREATE PROC up_OutputTest ( @i INT, @Output int output ) AS IF @i=1 BEGIN SET @Output=100 END IF @i=2 BEGIN SET @Output=200 END IF @Output IS NULL BEGIN SET @Output=0 END IF @Output IS NOT NULL BEGIN -- DOSOMETHING SET @Output=@Output+1 END GO -- 测试语句 DECLARE @i int, @Output int SET @i=1 WHILE @i<10 BEGIN EXEC up_OutputTest @i,@Output output SELECT @Output SET @i=@i+1 END
程序的实际输出为 101,201,202,203,204 ........................................ 与多少人的预期输出不一致 ?