title: Why my T-SQL (WHILE) does not work?
body: <p>In my code, I need to test whether specified column is null and the most close to 0 as possible (it can holds numbers from 0 to 50) so I have tried the code below.
  It should start from 0 and for each value test the query. When @Results gets null, it should return. However, it does not work. Still prints 0.</p>
  
  <pre><code>declare @hold int
  declare @Result int
  set @hold0
  set @Result=0
  
  WHILE (@Result!=null)
  BEGIN
  select @Result=(SELECT Hold from Numbers WHERE Name='Test' AND Hold=@hold)
  set @hold=@hold+1
  END
  
  print @hold
  </code></pre>