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»»»

Predict output Expand / Collapse
Author
Message
Posted Tuesday, January 19, 2010 9:25 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, July 3, 2012 5:49 AM
Points: 418, Visits: 365
Comments posted to this topic are about the item Predict output
Post #850204
Posted Tuesday, January 19, 2010 9:46 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, November 25, 2013 6:11 PM
Points: 118, Visits: 43
I would actually disagree with the answer given ...

Strictly speaking, the output is:

this is an exception ... in the messages pane ...

and then

1
2
4
5

in the results pane.

To my mind, the timing is important, as the "1,2,4,5" results are output AFTER the error message??
Post #850209
Posted Tuesday, January 19, 2010 11:11 PM
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: Saturday, March 30, 2013 6:06 AM
Points: 532, Visits: 224
Actullay the answer shoul be

this is an exception
id
-----------
1
2
4
5
Post #850243
Posted Wednesday, January 20, 2010 12:39 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: Thursday, July 3, 2014 9:19 PM
Points: 505, Visits: 1,691
There's been a bit of a biff about QoD answers lately, but there is really only one answer today as "this is an exception" will be output and only one choice offers that. The others either include "3" (which is not output) or do not complete the loop (which still happens.)

S.


Post #850263
Posted Wednesday, January 20, 2010 1:39 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, March 8, 2013 8:32 AM
Points: 26, Visits: 41
none of the suggested answers gives what I would call the correct output, which is a result of:

1,2,4,5

the following would be the messages created:
(1 row(s) affected)
(1 row(s) affected)
this is an exception
(1 row(s) affected)
(1 row(s) affected)
(4 row(s) affected)
Post #850283
Posted Wednesday, January 20, 2010 1:59 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 2:03 AM
Points: 1,388, Visits: 275
I have to agree here. None of the answers match what I would expect, which would be 'This is an exception' in the message pane, followed by the contents of the temp table: 1, 2, 4, 5.

However, when I ran this to try it out, I got an error:
(1 row(s) affected)

(1 row(s) affected)
this is an exception
Msg 208, Level 16, State 0, Line 10
Invalid object name '#temp'.


Which indicates that despite the try-catch block, the error caused the temp table to be dropped mid-execution.
Post #850298
Posted Wednesday, January 20, 2010 2:43 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: 2 days ago @ 2:53 AM
Points: 3,133, Visits: 3,402
Changing result to be in text, I get

(1 row(s) affected)

(1 row(s) affected)
this is an exception

(1 row(s) affected)

(1 row(s) affected)
id
-----------
1
2
4
5

(4 row(s) affected)


-------------------------------
Posting Data Etiquette - Jeff Moden
Smart way to ask a question

There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
Post #850318
Posted Wednesday, January 20, 2010 2:51 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, March 8, 2013 8:32 AM
Points: 26, Visits: 41
mzz3lh (1/20/2010)
I have to agree here. None of the answers match what I would expect, which would be 'This is an exception' in the message pane, followed by the contents of the temp table: 1, 2, 4, 5.

However, when I ran this to try it out, I got an error:
(1 row(s) affected)

(1 row(s) affected)
this is an exception
Msg 208, Level 16, State 0, Line 10
Invalid object name '#temp'.


Which indicates that despite the try-catch block, the error caused the temp table to be dropped mid-execution.


I ran this on sql server 2008 and did not get that behavior
Post #850320
Posted Wednesday, January 20, 2010 3:01 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 2:03 AM
Points: 1,388, Visits: 275
Yeah, I assumed SQL2008 might have been ok for this. I ran it on SQL2005 and got the error.

The Rollback Transaction statement seems to drop the temp table.
Post #850327
Posted Wednesday, January 20, 2010 3:11 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: Friday, May 9, 2014 12:47 AM
Points: 3,448, Visits: 4,407
mzz3lh (1/20/2010)
However, when I ran this to try it out, I got an error:
(1 row(s) affected)

(1 row(s) affected)
this is an exception
Msg 208, Level 16, State 0, Line 10
Invalid object name '#temp'.

Probably the IMPLICIT_TRANSACTIONS option is turned on.
Try this code:
SET IMPLICIT_TRANSACTIONS OFF
GO
... here comes the original script ...

Post #850334
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse