What will be the output of the following?

  • Answer provided is wrong it should be -1, 0, 1

    Else change the Identity to (-1,-1) to get the answer -1,-2,-3

  • Now that the points have been correctly awarded, those points received by discussion posts could be reduced: "Hey! I didn't get my point, I'll send ten posts to compensate..." :hehe:

  • It still says that -1,0,1 is wrong.

  • hilld (6/29/2010)


    It still says that -1,0,1 is wrong.

    I've said it before, I'll say it again - the question has been changed.

    Read the changed text of the question on the website. You'll see that with this question, -1,-,1 is no longer a correct answer. -1,-2,-3 is. (As is -3,-2,-1).


    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/

  • Ok, they changed the question. How do I change my answer now?

  • hilld (6/29/2010)


    Ok, they changed the question. How do I change my answer now?

    You can't. You always have to check the question on the website before answering. I believe there is a warning message in the daily mail to that effect (I am at least pretty sure there used to be in the past)


    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/

  • hilld (6/29/2010)


    Ok, they changed the question. How do I change my answer now?

    Don't worry about it... chill!

  • The question comes out in email, but we cannot edit that. If we find a typo, which fix it on the site, which contains the updated question and the answers. This is one reason we don't put the answers in the newsletter.

    If we find an issue, we mark the question correct for everyone to that point in time.

  • Maybe if someone posts to the discussion to point out an error in the question, the system could somehow check if there are already 10 posts saying the same thing, and if so deduct a point from the poster instead of awarding one 😉

  • Can the "Yesterday's question" and associated answer be edited prior to it being sent out?

  • Once it's edited on the site, it will go out as the corrected version.

  • Slight correction. It goes out edited in the next day's newsletter if it's not already scheduled. Sometimes we are scheduled out 2-3 days in a row.

  • in identity (-1,1) no first paramaeter shows number start from and second parameter shows number increment by mentioned. in that case "mainkey" will start from -1 and increased by 1. so Result will be

    -1,0,1.

    inf u will execute insert into MyTable default values

    then mainkey will be -1

    next time : insert into MyTable default values

    mainkey =mainkey +1

    so it will be 0

    next time : insert into MyTable default values

    mainkey =mainkey +1

    so it will be 1

    is it right ?

  • You are correct. The question was edited on the website to be (-1,-1). When you click through from the newsletter, that is what is shown.

  • I object.

    The question presented in the email had:

    mainkey int not null identity (-1,1)

    but the code in the question and answer on the web site had:

    mainkey int not null identity (-1,-1)

Viewing 15 posts - 121 through 135 (of 144 total)

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