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


While loop


While loop

Author
Message
sreenivas.kumarreddy
sreenivas.kumarreddy
SSC-Enthusiastic
SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)SSC-Enthusiastic (119 reputation)

Group: General Forum Members
Points: 119 Visits: 36
Comments posted to this topic are about the item While loop
bitbucket-25253
bitbucket-25253
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26817 Visits: 25280
Nice question as long as you read it carefully

Thanks

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
A.jafari
A.jafari
SSC Rookie
SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)SSC Rookie (33 reputation)

Group: General Forum Members
Points: 33 Visits: 66
Thanks For Good Question ,

Please illustrate diffrent between "Begin Catch" And "Try Except"


:-)Hehe
Thanks
Lokesh Vij
Lokesh Vij
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4770 Visits: 1599
Ah....an easy one. Thanks Sreenivas :-)

~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter


ziangij
ziangij
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4078 Visits: 380
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
demonfox
demonfox
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2995 Visits: 1192
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 BigGrin

Thanks.

~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one Ermm
Lokesh Vij
Lokesh Vij
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4770 Visits: 1599
demonfox (10/9/2012)
well, instead of 10/0.00001 try using 10/0 , guess what the answer could be BigGrin


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 :-D

~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter


Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)SSC Guru (111K reputation)

Group: General Forum Members
Points: 111460 Visits: 13338
Thanks for the question.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
kapil_kk
kapil_kk
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8361 Visits: 2777
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/
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27419 Visits: 7549
Good back-to-basics question, thanks

kapil190588 (10/10/2012)
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?


The final effect is the same, i.e. the variable @str is assigned the value of 1.
There are numerous minor differences between the actions.
Read about SET and SELECT.
the main difference is that the SET can be used to allocate a value to one variable at a time, while a SELECT can allocate multiple at the same time, e.g.
DECLARE @Var1 INT, @Var2 VARCHAR(25)
SET @Var1 = 5;
SET @Var2 = 'Hello ';
--OR--
SELECT @Var1 = 5, @Var2 = 'Hello '


With the advent of SQL2008, it is now possible to assign a value to a variable when declaring it (just as is done in coding in e.g. C# or vb, e.g.
DECLARE @Var1 INT = 5, @Var2 VARCHAR(25) = 'Hello '
SELECT @Var1 *= @Var1, -- will render as 25
@Var2 += SUSER_SNAME()
SELECT @Var1, @Var2



____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
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