可能遗漏了一些明显的东西,但我无法让nested while loop
正常运作。如果我注释掉内部while,则外部while按预期工作,但是否则只执行内部while。我已经剔除了要执行的实际代码,试图帮助解决这个问题,这就是为什么它只显示变量的内容。我确信这是一件很简单的事情,我很想念,但是我已经在这一段时间里一直在努力,所以希望有人可以提供帮助!
DECLARE @WeekCounter AS int
DECLARE @ClientCounter AS int
SET @WeekCounter = 1
SET @ClientCounter = 1
WHILE @ClientCounter <= 3
BEGIN
WHILE @WeekCounter <= 2
BEGIN
SELECT @ClientCounter,@WeekCounter
SET @WeekCounter = @Weekcounter + 1
END
SET @ClientCounter = @ClientCounter + 1
END
由于
答案 0 :(得分:1)
工作代码 -
DECLARE @WeekCounter AS int
DECLARE @ClientCounter AS int
SET @ClientCounter = 1
---------Set client info from counter--------------
WHILE @ClientCounter <= 3
BEGIN
SET @WeekCounter = 1
WHILE @WeekCounter <= 2
BEGIN
SELECT @ClientCounter,@WeekCounter
SET @WeekCounter = @Weekcounter + 1
END
SET @ClientCounter = @ClientCounter + 1
END