October 9, 2012 at 8:14 pm
Comments posted to this topic are about the item While loop
October 9, 2012 at 8:15 pm
October 9, 2012 at 9:40 pm
Thanks For Good Question ,
Please illustrate diffrent between "Begin Catch" And "Try Except"
:-):hehe:
Thanks
October 9, 2012 at 9:56 pm
Ah....an easy one. Thanks Sreenivas
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
October 9, 2012 at 10:07 pm
Thanks for the question. It seems that the catch block is just for confusing coz. the select query in the catch block doesn't execute
October 9, 2012 at 10:20 pm
yes, nice question; try and catch doesn't hold anything.. even if you put the above code in a transaction it would still give 11.
well, instead of 10/0.00001 try using 10/0 , guess what the answer could be
Thanks.
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
October 9, 2012 at 11:03 pm
demonfox (10/9/2012)
well, instead of 10/0.00001 try using 10/0 , guess what the answer could be
Initially I thought this division is the key to answer this question; as "0.00001" is nearly equal to zero, the statement 10/0.00001 will introduce "divide by zero" error and hence catch block will come into picture :hehe:
All these wacky thoughts went away and I marked the correct answer. Thanks to the "Espresso Coffee" which did the magic
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter
October 9, 2012 at 11:16 pm
Thanks for the question.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 10, 2012 at 12:30 am
Hi,
I am new in field of DBA...
I just want to know that can we assign value to a variable through SELECT statement also as done in the
question
Select @str=1,
whts the difference between -
Set @str=1
select @str=1
in this quesion?
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
October 10, 2012 at 1:33 am
thanks Stewart for the explanation...
Learned something new today
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
October 10, 2012 at 2:29 am
Lokesh Vij (10/9/2012)
demonfox (10/9/2012)
well, instead of 10/0.00001 try using 10/0 , guess what the answer could beInitially I thought this division is the key to answer this question; as "0.00001" is nearly equal to zero, the statement 10/0.00001 will introduce "divide by zero" error and hence catch block will come into picture :hehe:
All these wacky thoughts went away and I marked the correct answer. Thanks to the "Espresso Coffee" which did the magic
well yes, catch block would come into the picture ; and the answer would be 4 ; the loop continues till codition breaks that.
Declare @ctr int
select @ctr = 1
while @ctr <= 10
begin
select '1'
if @ctr = 4
select 10/0
select @ctr = @ctr+1
end
end try
begin catch
select @ctr
end catch
select @ctr 'Counter'
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
October 10, 2012 at 2:32 am
Decent question with lots of red herrings, many thanks
---
Note to developers:Want to get the best help? Click here https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help (Jeff Moden)
My blog: http://uksqldba.blogspot.com
Visit http://www.DerekColley.co.uk to find out more about me.
October 10, 2012 at 3:53 am
A.jafari (10/9/2012)
Please illustrate diffrent between "Begin Catch" And "Try Except"
You can read about TRY ... CATCH here: http://msdn.microsoft.com/en-us/library/ms175976.aspx
In T-SQL, "Try Except" is invalid syntax. I have no idea what language this comes from and what it does, but it sounds as just a slightly different way to solve the same problem (error handling).
October 10, 2012 at 5:04 am
Thank you for the question.
I was almost choosing the error answer because of the 10/0.00001 but then I drank some coffee and thought about it for one more second.
Best regards,
Andre Guerreiro Neto
Database Analyst
http://www.softplan.com.br
MCITPx1/MCTSx2/MCSE/MCSA
Viewing 15 posts - 1 through 15 (of 38 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy