Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Predict output


Predict output

Author
Message
arup chakraborty
arup chakraborty
SSC-Addicted
SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)SSC-Addicted (458 reputation)

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

Group: General Forum Members
Points: 120 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 (534 reputation)Mr or Mrs. 500 (534 reputation)Mr or Mrs. 500 (534 reputation)Mr or Mrs. 500 (534 reputation)Mr or Mrs. 500 (534 reputation)Mr or Mrs. 500 (534 reputation)Mr or Mrs. 500 (534 reputation)Mr or Mrs. 500 (534 reputation)

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

this is an exception
id
-----------
1
2
4
5
Fal
Fal
Mr or Mrs. 500
Mr or Mrs. 500 (522 reputation)Mr or Mrs. 500 (522 reputation)Mr or Mrs. 500 (522 reputation)Mr or Mrs. 500 (522 reputation)Mr or Mrs. 500 (522 reputation)Mr or Mrs. 500 (522 reputation)Mr or Mrs. 500 (522 reputation)Mr or Mrs. 500 (522 reputation)

Group: General Forum Members
Points: 522 Visits: 1803
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 (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)

Group: General Forum Members
Points: 32 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
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1430 Visits: 321
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
SSCarpal Tunnel
SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)

Group: General Forum Members
Points: 4485 Visits: 4549
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
nomlad
nomlad
SSC Rookie
SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)SSC Rookie (32 reputation)

Group: General Forum Members
Points: 32 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
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1430 Visits: 321
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
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3494 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