SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Predict output


Predict output

Author
Message
arup chakraborty
arup chakraborty
SSC Eights!
SSC Eights! (996 reputation)SSC Eights! (996 reputation)SSC Eights! (996 reputation)SSC Eights! (996 reputation)SSC Eights! (996 reputation)SSC Eights! (996 reputation)SSC Eights! (996 reputation)SSC Eights! (996 reputation)

Group: General Forum Members
Points: 996 Visits: 365
Comments posted to this topic are about the item Predict output
Paul Marriott-463518
Paul Marriott-463518
SSC-Enthusiastic
SSC-Enthusiastic (172 reputation)SSC-Enthusiastic (172 reputation)SSC-Enthusiastic (172 reputation)SSC-Enthusiastic (172 reputation)SSC-Enthusiastic (172 reputation)SSC-Enthusiastic (172 reputation)SSC-Enthusiastic (172 reputation)SSC-Enthusiastic (172 reputation)

Group: General Forum Members
Points: 172 Visits: 46
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??
jagadeesanpv
jagadeesanpv
Mr or Mrs. 500
Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)Mr or Mrs. 500 (592 reputation)

Group: General Forum Members
Points: 592 Visits: 224
Actullay the answer shoul be

this is an exception
id
-----------
1
2
4
5
Fal
Fal
Right there with Babe
Right there with Babe (782 reputation)Right there with Babe (782 reputation)Right there with Babe (782 reputation)Right there with Babe (782 reputation)Right there with Babe (782 reputation)Right there with Babe (782 reputation)Right there with Babe (782 reputation)Right there with Babe (782 reputation)

Group: General Forum Members
Points: 782 Visits: 1809
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.
nomlad
nomlad
SSC Rookie
SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)

Group: General Forum Members
Points: 46 Visits: 45
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)
SQLTuna
SQLTuna
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1464 Visits: 328
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.
Stuart Davies
Stuart Davies
SSCertifiable
SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)SSCertifiable (7.4K reputation)

Group: General Forum Members
Points: 7406 Visits: 4820
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 questionThere 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
nomlad
nomlad
SSC Rookie
SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)

Group: General Forum Members
Points: 46 Visits: 45
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
SQLTuna
SQLTuna
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1464 Visits: 328
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.
vk-kirov
vk-kirov
SSCarpal Tunnel
SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)SSCarpal Tunnel (4.3K reputation)

Group: General Forum Members
Points: 4340 Visits: 4408
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 ...


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search