What will be the output of the following?

  • The points are nice because of the running totals in each of the various categories. It lets me know my strengths and more importantly my weaknesses. But I agree, that the number of responses here is a good thing; it shows that we have a large community of talented people who try their best to make sure everything is timely and accurate. Keep up the good work everyone!

  • kevin.l.williams (6/28/2010)


    Sorry if this was already covered. I did read through the 11 pages :doze: and didn't see much on the subject of sort order. Without a specified order wouldn't -3, -2, -1 also be a correct answer?

    Yup, that has been pointed out. By me, and probably by others as well, but a bit hard to find in between all the superfluous "me too" and "gimme my point" posts.

    Steve Jones - Editor (6/28/2010)


    It could be. Good catch, Kevin.

    But unless I miss something, new visitors who see the corrected version of the question will get a point for the (now correct) -1,-2,-3 answer, but not get a point for the equally correct -3,-2,-1 answer. I think you should fix that as well!

    (Oh, and BTW - thanks for fixing the other issue!)


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Steve Jones - Editor (6/28/2010)


    It could be. Good catch, Kevin.

    Hey Steve did you correct Friday's question too ("SELECT @local_variable")? When I run the code I really get a,b,c and not C as stated in the real answer.

  • Question must have been fixed by the time I answered.

    Thanks for the QOD.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • CirquedeSQLeil (6/28/2010)


    Question must have been fixed by the time I answered.

    Thanks for the QOD.

    Me too. I began reading the discussion and thought the first few simply missed the "-" but it went on and on, so I figured it had been corrected by the time I got to it.:-)

  • funny, teach me to read the question in the email, then read it again when I hit the site... they could very well be different questions... an annoying test in observation!

  • Duncan Pryde (6/28/2010)


    Changing the subject somewhat...

    Although I knew that you can have negative seeds and increments for the IDENTITY property, I've never actually used them myself.

    I'd therefore be interested to hear if anyone else had used them, and in what sort of situations?

    Duncan

    Two live web servers, one on each coast. The two DB's replicate between themselves. On one coast, the identity columns are set to (-1,-1), and on the other they are set to (1,1) so that new records can be added to each server without stomping on each other. There probably is a better way, but this was done before I came here. Since this (again, before I came here), they consolidated the two servers into one, so we don't have this anymore... but we are dealing with both ranges of numbers (oh.. and guess which was is the consolidated database... yep, (-1,-1) )

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • WayneS (6/28/2010)


    Duncan Pryde (6/28/2010)


    Changing the subject somewhat...

    Although I knew that you can have negative seeds and increments for the IDENTITY property, I've never actually used them myself.

    I'd therefore be interested to hear if anyone else had used them, and in what sort of situations?

    Duncan

    Two live web servers, one on each coast. The two DB's replicate between themselves. On one coast, the identity columns are set to (-1,-1), and on the other they are set to (1,1) so that new records can be added to each server without stomping on each other. There probably is a better way, but this was done before I came here. Since this (again, before I came here), they consolidated the two servers into one, so we don't have this anymore... but we are dealing with both ranges of numbers (oh.. and guess which was is the consolidated database... yep, (-1,-1) )

    So what??? it's still a freaking unique id :hehe:;-):w00t:

  • i am getting -1, 0, 1

    how come u r getting -1,-2,-3 ? pLz explain.......

  • Me too getting "-1,0,1" but available answer is "-1,-0,1" :w00t:

    ---------------------------------------------------
    "Thare are only 10 types of people in the world:
    Those who understand binary, and those who don't."

  • sunitagaikwad (6/28/2010)


    i am getting -1, 0, 1

    how come u r getting -1,-2,-3 ? pLz explain.......

    There was a typo in the question, that has been corrected after the newsletter was sent out. If you check the code on the website, you'll see that this code will indeed return -1,-2,-3 (or-3,-2,-1 - as there is no ORDER BY in the SELECT statement).

    Always check for changes to the question before answering. Especially if more than a few hours have passed between sending the email and answering the question.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Perhaps we need some Quality Control on QOD.

    Changing the question after people have started submitting answers - that seems a bit unfair to me...

  • paul s-306273 (6/29/2010)


    Perhaps we need some Quality Control on QOD.

    Changing the question after people have started submitting answers - that seems a bit unfair to me...

    Maybe you should read the previous reactions in the topic first....

    What happens is that there was a typo in the question. So people gave an answer that was correct for the question as published, but wrong for the question as intended; and they did not get points for it.

    When Steve got to work, he noticed the problems. He then corrected the question, and awarded points back to those who had already replied to the question because they missed the point through no fault of their own.

    If you consider it unfair to change the question after people have submitted answers, does that imply that you think he should have left the incorrect question unchanged?


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Answer is -1,0,-1

    if(marked answer == -1,-0,1)

    { give points to those persons }

    else

    { delete this questions/thread }

  • I thought this looked wrong, so I tried it.

    I also got -1, 0, 1 from this code

Viewing 15 posts - 106 through 120 (of 144 total)

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