如何在存储过程内的循环中增加局部变量的值
ALTER PROC [dbo].[Usp_SelectQuestion]
@NoOfQuestion int
AS
BEGIN
Declare @CNT int
Declare @test int
Declare @x int
Declare @y int
set @x = 1;
set @y = 1;
Select @CNT=(Select Count(*) from (select Distinct(setno)from onlin) AS A)
select @test=@NoOfQuestion/@CNT
while @x <= @CNT do
while @y <= @test
select * from onlin where setno = @x
set @y = @y +1
set @x =@x + 1
END
像@x
和@y
不递增的值,我陷入了无限循环。