if OBJECT_ID('tempdb..#temp') is not nulldrop table #tempselect * into #temp from ( --select * from Activity select 7 as 'month',25 as 'day' union all select 7 as 'month',25 as 'day' union all select 8 as 'month',25 as 'day' union all select 8 as 'month',25 as 'day' union all select 8 as 'month',25 as 'day' ) as Aselect * from #temp