日期:2014-05-17 浏览次数:20509 次
DECLARE @i INT, @h INT,@Nun INT SET @i = 0 SET @h = 0 SET @Nun = 1 WHILE @i < 5 /*循环一*/ BEGIN WHILE @h < 5/*循环二*/ BEGIN PRINT @Nun /*循环一加循环二这里输出应该是25次才对,但他只输出了5次。*/ SET @Nun=@Nun+1 SET @h = @h + 1 END SET @i = @i + 1 END
DECLARE @i INT, @h INT,@Nun INT SET @i = 0 --SET @h = 0 SET @Nun = 1 WHILE @i < 5 /*循环一*/ BEGIN SET @h = 0 WHILE @h < 5/*循环二*/ BEGIN PRINT @Nun /*循环一加循环二这里输出应该是25次才对,但他只输出了5次。*/ SET @Nun=@Nun+1 SET @h = @h + 1 END SET @i = @i + 1 END
------解决方案--------------------
DECLARE @i INT, @h INT,@Nun INT SET @i = 0 SET @Nun = 1 WHILE @i < 5 /*循环一*/ BEGIN SET @h = 0 WHILE @h < 5/*循环二*/ BEGIN PRINT @Nun /*循环一加循环二这里输出应该是25次才对,但他只输出了5次。*/ SET @Nun=@Nun+1 SET @h = @h + 1 END SET @i = @i + 1 END /*1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 */