sharath.chalamgari (6/18/2010)
i tried with "ma-516002" query in the 2005 version the results are same i am able to get the records from both the tables. when i tried something simila with my local database tables i am getting records from only one table.in both the cases it is creating table with the not null constraint
looks Weird.....
use the corrected code below, and see what you get.
if object_id('tempdb.dbo.#mytmp') is not null
drop table #mytmp
go
declare @myothertab table (
col2 varchar(20),
col3 varchar(20)
)
insert into @myothertab
select 'A','B' union all
SELECT 'W','Q'
;
declare @myanothertab table (
col2 varchar(20),
col3 varchar(20)
)
insert into @myanothertab
select 'A2','B2' union all
SELECT 'W2','Q2';
select 1 as col1, col2, col3 into #mytmp
from @myothertab
insert into #mytmp
select null,col2,col3
from @myanothertab
select * from #mytmp