Blog Pages

select ... into ... union

declare @a table (aint int)
declare @b table (bint int)

insert into @a (aint) values (1), (2), (3)
insert into @b (bint) values (1), (2), (4), (6)

If you need to insert an union select into a temp table, like this:
select * into #tmp
from (select aint from @a union select bint from @b) t

You can also do it like this:
select aint
into #tmp
from @a
union
select bint
from @b

Check it:
select * from #tmp

(and also drop the temp table :) drop table #tmp )

No comments:

Post a Comment