title: Table variables inside while loop not initializing everytime : SQL Server
body: <p>I am wondering why the table variables inside while loop does not behave like other variables. Table variables created only once and will be used across through out whole looping. but other variables getting initialized every time when loop increases.    </p>
  
  <p>Check out the below code for more info</p>
  
  <pre><code>declare @tt int
  set @tt =10
  while @tt&gt;0
  begin
  
          declare @temptable table(id int identity(1,1),sid bigint)
          insert into @temptable 
                  select @tt union all
                  select @tt + 1 
  
                  select * from @temptable 
                 --delete from @temptable
                  set @tt=@tt-1
  end
  </code></pre>
  
  <p>is this a bug??</p>