table variable vs temp table

Viewed 449
declare  @i int = 1
if (@i= 2)
Begin 
    declare @t table (value int)
    insert into @t 
    select 1
    select * from @t
end
else 
    select *from @t  
---------------
declare  @i int = 1
if (@i= 2)
Begin 
    create table #t(value int)
    insert into #t
    select 1
end
else 
    select *from #t 

Why table variable is not getting invalid object name in this?

3 Answers
Related