Click here to Skip to main content
15,914,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
--
SQL
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

SQL
insert into #tempfreeze ([Hub Id])
select 18
union all select 574


SQL
select * from #tempfreeze
set @hubcount=(select count(*) from  #tempfreeze)


print @hubcount


I am selecting everything and pressing f5. Then the print command doesnt get executed.
Posted
Updated 8-Aug-13 3:26am
v3

1 solution

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
SQL
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
 
Share this answer
 
Comments
anurag19289 8-Aug-13 9:34am    
ooops oops oops... i got it .... thanks
Fredrik Bornander 8-Aug-13 10:04am    
Glad I could help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900