What will be the output of the following?

  • bazzkar

    SSC Veteran

    Points: 270

    Comments posted to this topic are about the item What will be the output of the following?

  • Paarthasarathy

    SSChasing Mays

    Points: 649

    how come.. i am getting -1,0,1 only..

    someone explain please

    Kindest Regards,
    Paarthasarathy
    Microsoft Certified Technology Specialist
    http://paarthasarathyk.blogspot.com

  • Piotr ER

    SSCertifiable

    Points: 5571

    first - all available answers are wrong. "-1,-0,1" is the better looking although you will not get "-0"

    second - with identity (-1,1) you can only get -1, 0, 1. If you want to get -1,-2,-3 you would need identity(-1,-1)

    There is something wrong with either question or with the answers.

  • sheik

    SSChasing Mays

    Points: 660

    The table should be created with the identity (-1,-1). Then only we can get this result. Must be a typo error???.

  • john-byrne

    SSCommitted

    Points: 1852

    Since the question is wrong then everyone who selected "-1,0,1" should get a point!

    :-):-D

  • bhandari220

    SSC-Addicted

    Points: 402

    Yes, To get -1,-2,-3 identity should be -1 insteed of 1.

    Regards,

    Pankaj Bhandari

    Microsoft Certified Technology Specialist

  • ziangij

    SSCertifiable

    Points: 6523

    Yeah!... i have executed the query in SSMS 2005... and I get the result as "-1,0,1"

    we should get our points back... 😀

    john-byrne (6/27/2010)


    Since the question is wrong then everyone who selected "-1,0,1" should get a point!

    :-):-D

  • Nakul Vachhrajani

    SSChampion

    Points: 10040

    With an identity of (-1,1), -1, -2 and -3 is just not the possible output.

    The first record that goes in will have -1. Next would be -1 + 1 = 0. Finally, we would have 0 + 1 = 1.

    It's probably just a typo, and I am sure the moderators will take a look and award the points.

    The points not being awarded is a typical drawback with the automated evaluation systems - after all, all automation works on GIGO. If there was an error in framing the question, there's bound to be an error in the evaluation. Just another example of why automation should not be allowed work without supervision 🙂

    Thanks & Regards,
    Nakul Vachhrajani.
    http://nakulvachhrajani.com
    Be courteous. Drive responsibly.

    Follow me on
    Twitter: @sqltwins
    Google Plus: +Nakul

  • sumedha_2001jhanji

    SSC Journeyman

    Points: 80

    The answer is -1,0,1. The provided answer is wrong. To get -1,-2,-3, we have to set the identity increment as -1.

    Juts give the points... 10 times of the actual point..... 😉

  • chetanr.jain

    Hall of Fame

    Points: 3938

    Even i am getting the answer as "-1, 0, 1".

    I have executed the query in SQL 2008 Enterprise edition.

    i am agreeing with others about the fact that

    to get ans as -1, -2, -3, the seed value should be -1.

    @Moderator :

    Look in this.

  • ramaratna

    Valued Member

    Points: 56

    itseems like the answer or question posted is wrong!! 🙂

  • malleswarareddy_m

    SSCertifiable

    Points: 5847

    Create Table MyTable( mainkey int not null identity (-1,1))

    GO

    insert into MyTable default values insert into MyTable default values insert into MyTable default values

    Select * from MyTable

    this will give result as this

    -1

    0

    1

    I think this type of question three weeks ago.this question is similar to the question on may 31 st 2010.

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

  • malleswarareddy_m

    SSCertifiable

    Points: 5847

    sheik (6/27/2010)


    The table should be created with the identity (-1,-1). Then only we can get this result. Must be a typo error???.

    It's correct.

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

  • sukhendass

    Old Hand

    Points: 322

    i think there is something wrong with this answer coz it should be

    -1,0,1 but ans is -1,-2,-3.

  • rene.moosens

    SSCrazy

    Points: 2025

    I'm getting -1, 0, 1 as I would expect to be the right answer ( as almost all contributors)

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

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