title: how to increment a value inside stored procedure
body: <p>How to increment a value of local variable in the loop inside a stored procedure</p>
  
  <pre><code>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 &lt;= @CNT do 
      while @y &lt;= @test
          select  * from onlin where setno = @x
          set @y = @y +1
      set @x =@x + 1 
  END
  </code></pre>
  
  <p>the values like <code>@x</code> and <code>@y</code> is not incrementing and I am stuck in an infinite loop.</p>