|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 12:06 AM
Points: 1,846,
Visits: 974
|
|
I got 10 rows.I am using sqlserver 2008.
I think the author answer is correct.It s depends
Malleswarareddy I.T.Analyst MCITP(70-451)
|
|
|
|
|
SSC Rookie
      
Group: General Forum Members
Last Login: Monday, September 10, 2012 7:49 AM
Points: 49,
Visits: 10
|
|
| I don't think there was an "it depends" answer. It seems the question is flawed to the point where you can't say that a single answer is always true, most people who have responded thus far got the error, not a set of records.
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Today @ 7:39 AM
Points: 9,370,
Visits: 6,467
|
|
Nice question and an important point, but I have executed the code a 100 times or more and I always get the error. Statistically I'm allowed to say that the correct answer is the error 
edit: pfiew, it took me a long time before I could post on this thread because the site went down. When I went back to the questions I got the SSC maintenance screen. After a few hours I still got the maintenance screen, so I had to manually flush the cache of internet explorer to be able to see the questions again.
How to post forum questions. Need an answer? No, you need a question. What’s the deal with Excel & SSIS?
Member of LinkedIn. My blog at LessThanDot.
 MCSA SQL Server 2012 - MCSE Business Intelligence
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 8:49 AM
Points: 2,672,
Visits: 2,417
|
|
| Interesting question, even more interesting explanation. Hmmm. I guess my take away from this question, is don't use temp tables in stored procedures.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232,
Visits: 1,046
|
|
The question clearly states "What will be the results of the following?". Not what does the Books Online say about nested temp tables using the same name.
Why is the answer for a differant question?
Why do you say that this code is compatable on versions of SQL server it is not?
This is the type of confusing trick question that requires the ability to read the authors mind to resolve.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 6:20 AM
Points: 2,035,
Visits: 930
|
|
Tricky question/answer -not sure if I would ever use the information learned with this one either.
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Thursday, June 30, 2011 3:44 AM
Points: 971,
Visits: 62
|
|
The problem is that when you run the code as is, you will not get to Proc3; If you do, you get the answer that you are looking for. But since proc2 is run from proc1, and the temp table is still in actual scope, you will get Answer C, which is an error message and stops the processing at the insert inside of Proc2. Thus when Proc3 is executed and the temp table is not defined and you would get the answer that you list as correct.
Now, I read the section highlighted in BOL, and I expected to get the not defined error message, but I would need to look further and see why, #test1 still was available to Proc2. It should have created a new version of #test1, but it did not, it saw the version created within Proc1.
So for everyone that got the mismatch column error, what is different about our setup then the one that should match the BOL.
I am running SS2K8 Developer Edition, with the latest patches, but not R2.
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Today @ 12:39 PM
Points: 3,397,
Visits: 3,405
|
|
| A very interesting question but I am not sure the answer is completely correct? Seems like the contents of the temp table would be within the scope of the last stored procedure to create the temp table. So 10 records.
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 11:54 AM
Points: 749,
Visits: 3,767
|
|
Interesting question Wayne - Thanks!
______________________________________________________________________ The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Yesterday @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|