While loop 2

  • sreenivas.kumarreddy

    SSC Enthusiast

    Points: 143

    Comments posted to this topic are about the item While loop 2

  • Ron McCullough

    SSC Guru

    Points: 63877

    Thanks for a good question - good thing I had my coffee before answering

    Again 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[/url]
    Before posting a performance problem please read[/url]

  • Lokesh Vij

    SSChampion

    Points: 10836

    Thanks Sreenivas for the question. Indeed we discussed the situation of "Divide by zero error" in your earlier QOTD discussion forum "While Loop - 1".

    All in all ending this week on a good note 🙂

    ~ Lokesh Vij


    Guidelines for quicker answers on T-SQL question[/url]
    Guidelines for answers on Performance questions

    Link to my Blog Post --> www.SQLPathy.com[/url]

    Follow me @Twitter

  • Jamsheer

    Ten Centuries

    Points: 1136

    Good Morning Sreeni.. Thanx for the easy Point..

  • malleswarareddy_m

    SSCertifiable

    Points: 5847

    Thanks for good question. Error is because of data type. SQLserver implicitly convert float into integer for @B variable. Hence divide by zero error encountered.

    Malleswarareddy
    I.T.Analyst
    MCITP(70-451)

  • kapil_kk

    SSC-Insane

    Points: 21316

    I am newbie..

    can anyone explain me why divide by zero error encountered...

    as 10/.001 is thr

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • kapil_kk

    SSC-Insane

    Points: 21316

    Oopes I am clear with answer now..

    I confused with the byte size of int and float so select wrong answer... 🙁 🙁

    as .001 will will gets converted into 0 so when counter moves to 4 it will show error 'divide by zero encountered'

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • palotaiarpad

    SSCarpal Tunnel

    Points: 4889

    Easy points in a row, fine. 🙂

  • derek.colley

    SSCrazy Eights

    Points: 8040

    Good question, thank you. Had to read twice to make sure I wasn't missing a 'trick'!

    ---

    Note to developers:
    CAST(SUBSTRING(CAST(FLOOR(NULLIF(ISNULL(COALESCE(1,NULL),NULL),NULL)) AS CHAR(1)),1,1) AS INT) == 1
    So why complicate your code AND MAKE MY JOB HARDER??!:crazy:

    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.

  • Koen Verbeeck

    SSC Guru

    Points: 258941

    Nice question, thanks!

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • demonfox

    SSCertifiable

    Points: 6289

    Lokesh Vij (10/11/2012)


    Thanks Sreenivas for the question. Indeed we discussed the situation of "Divide by zero error" in your earlier QOTD discussion forum "While Loop - 1".

    All in all ending this week on a good note 🙂

    And I didn't have to rethink for this one..;-):w00t::hehe:

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • baabhu

    SSCertifiable

    Points: 6202

    Damn it. Answered the question fast. Did not see the variable @B is int.

  • Divine Flame

    SSCoach

    Points: 15941

    Easy one to end the week. Thanks Sree 🙂


    Sujeet Singh

  • DugyC

    Hall of Fame

    Points: 3804

    Darn! Saw the question, and for a few various reasons I thought it was the same question as the last time, and presumed a mistake with SSC or caching or something, so answered same as last time and Doh! Wrong!

    That'll teach me not to pay attention :doze:

    _____________________________________________________________________
    [font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]

  • (Bob Brown)

    SSCrazy

    Points: 2705

    Thanks for the easy question to end the week on a high note!

Viewing 15 posts - 1 through 15 (of 30 total)

You must be logged in to reply to this topic. Login to reply