This is the table creation and insertion query
If not exists(select * from sysobjects where name='hrs') Create table hrs(hr int) declare @cnt int =1 while @cnt <= 12 begin insert into hrs values(@cnt) set @cnt=@cnt+1 end
The above code gives the output like
declare @cnt1 int = 1
while @cnt1<=12
begin
EXEC('select he'+@cnt1+' = case when hr = 1 then '+@cnt1+' end from hrs')
set @cnt1=@cnt1+1
end
The above code returns the 12 different table but i just want the all records in one table (without creating any new table).
So, how can i do this?
Please help me.
Thanks.