title: While loop in Stored Procedure doesnt work
body: <p>I'm working on a database(school project). I need some testing for that database(SQL Server 2008 R2).</p>
  
  <p>I'm trying to test its recovery. There for i'm building a stored procedure so that it takes long enough to crash my pc.</p>
  
  <p>The problem is that the while loop that i'm using doenst seems to work.</p>
  
  <p>Stored procedure:</p>
  
  <pre><code>USE [OnderzoekSQL]
  GO
  
  SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  
  ALTER PROCEDURE [dbo].[Test_pro_opnemen] 
  -- Add the parameters for the stored procedure here
  @bnummer int OUT,
  @i int
  
  AS
  BEGIN
  
  SET NOCOUNT ON;
  WHILE(@i &lt;= @@ROWCOUNT )
      -- Insert statements for procedure here
      SELECT TOP 1 @bnummer = accountnumber
      FROM dbo.bank 
      ORDER BY saldo DESC
  
      PRINT @bnummer
  
      UPDATE bank
      SET saldo = '0'
      WHERE accountnumber = @bnummer
      SET @i = @i+1
  
  END
  </code></pre>
  
  <p>And the table:</p>
  
  <pre><code>CREATE TABLE [dbo].[bank](
  [accountnumber] [nvarchar](50) NOT NULL,
  [saldo] [real] NULL,
  [owner_id] [int] NULL;
  </code></pre>
  
  <p>And about the difference between the nvarchar and the int of accountnumber. It doesnt really matter because i only use number in accountnumber.</p>
  
  <p>The procedure work if i remove the While loop</p>