When you are running this, make sure you run both the declaration and the statements.
If you open a new Query window in SQL Server Management Studio and paste
create table #tempfreeze
(
[TotalRow] int identity(1,1),
[Hub Id] int,
[Number of Routes Executed] int,
[Neither vehicle nor vendor] int,
[Only vendor assigned] int,
[Vehicle is assigned] int,
[Number of Routes Freezed] int
)
declare @routefreeze int,
@hubcount int,
@counterloop int,
@rownow int,
@hubnow int
insert into #tempfreeze ([Hub Id])
select 18
union all select 574
select * from #tempfreeze
set @hubcount=(select count(*) from #tempfreeze)
print @hubcount
And then, without selecting anything just execute the entire query, it will work.
Hope this helps,
Fredrik