Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12345»»»

Nested Temporary Tables Expand / Collapse
Author
Message
Posted Thursday, December 16, 2010 3:40 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, November 25, 2014 11:09 PM
Points: 1,940, Visits: 1,173
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)
Post #1035728
Posted Thursday, December 16, 2010 3:42 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC 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.
Post #1035730
Posted Thursday, December 16, 2010 6:17 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 12:52 PM
Points: 13,636, Visits: 11,509
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
Post #1035784
Posted Thursday, December 16, 2010 7:37 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, December 12, 2014 8:24 AM
Points: 2,818, Visits: 2,567
Interesting question, even more interesting explanation. Hmmm. I guess my take away from this question, is don't use temp tables in stored procedures.
Post #1035836
Posted Thursday, December 16, 2010 7:43 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,228, 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.
Post #1035842
Posted Thursday, December 16, 2010 8:08 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, December 16, 2014 8:32 AM
Points: 2,655, Visits: 1,058
Tricky question/answer -not sure if I would ever use the information learned with this one either.
Post #1035864
Posted Thursday, December 16, 2010 8:13 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!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.
Post #1035869
Posted Thursday, December 16, 2010 8:18 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, November 10, 2014 12:05 PM
Points: 3,969, Visits: 3,648
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.
Post #1035871
Posted Thursday, December 16, 2010 8:19 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, November 19, 2014 3:46 PM
Points: 598, Visits: 3,821
Interesting question Wayne - Thanks!

______________________________________________________________________
The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking
Post #1035872
Posted Thursday, December 16, 2010 8:22 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 3:20 PM
Points: 18,064, Visits: 16,099
Paul Peeters (12/16/2010)
The real error that is displayed is "Incorrect syntax" because there is a non-matching closing parenthesis in the select statement in dbo.Proc1


Look more closely. At first glance it appears that way but the parentheses match.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1035874
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse