|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Friday, January 18, 2013 5:32 AM
Points: 61,
Visits: 171
|
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, April 30, 2013 7:26 PM
Points: 254,
Visits: 277
|
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: 2 days ago @ 8:01 PM
Points: 408,
Visits: 688
|
|
Thanks, got it wrong and learning something :)
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:53 AM
Points: 1,530,
Visits: 359
|
|
good question... thanks 
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 4:14 AM
Points: 1,852,
Visits: 988
|
|
got it wrong and i thought that, 1 as something in select into statement by default it will allows.but learned that it will not allows null.I worked more on select ..into but still got wrong.
good question.learned one point.
Malleswarareddy I.T.Analyst MCITP(70-451)
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 7:51 AM
Points: 1,085,
Visits: 1,166
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Monday, May 06, 2013 3:27 AM
Points: 1,864,
Visits: 297
|
|
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 @myothertab select 'A','B' union all SELECT 'W','Q';
select 1 as col1, col2, col3 into #mytmp from @myothertab insert into #mytmp select null,col2,col3 from @myanothertab
select * from #mytmp
returns 4 rows on SS2008 contrary to your explanation. why?
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Friday, January 18, 2013 5:32 AM
Points: 61,
Visits: 171
|
|
Hi, the point is the creation of a table column with a constant. - eg 1 or 'A' - in this case a not null constraint is added to this column when select .. into is used.
on msdn nor the books online i've found why this happened.
learned that by getting errors 
kind regards Matthias
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Yesterday @ 7:52 AM
Points: 582,
Visits: 1,603
|
|
ma-516002 (6/17/2010) 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 @myothertab select 'A','B' union all SELECT 'W','Q';
select 1 as col1, col2, col3 into #mytmp from @myothertab insert into #mytmp select null,col2,col3 from @myanothertab
select * from #mytmp
returns 4 rows on SS2008 contrary to your explanation. why?
There's an error in your sql above. You're inserting twice into the same table (@myothertab) and not at all into @myanothertab.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, September 17, 2012 7:30 AM
Points: 1,038,
Visits: 679
|
|
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.....
|
|
|
|