INSERT INTO

  • I agree with what the question was trying to show, however I believe the answers were wrong for the following reason (and you could select 4). Both inserts will generate an error message, however the second one will succeed on the first row, while the first fails as a complete transaction, hence count 0 for first table, and 1 for second table.

    Either the answer should be that the second select returns 1, or the second insert will succeed as well as fail.

    I also think that what probably happened is that the second insert was miss-copied! If you look at the first statement you have cid of 1 , 2 and 2, while the second table has 1, 1 and 1 (lazy copy/paste). If the inserts were meant to try insert the same data into both tables, then there would have been 2 rows in the second table.

    That said, we need to get our points back - particularly since the question asks for 4 answers and there are possibly 5...

  • Beaten to it. :laugh:

    There are only three correct answers but the question has emphasized a very good point with regards to the insertion of multiple values in SQL2008.

  • A good question, unfortunately it came down to "guess the typo". Fortunately I guessed right that the values inserted into cuss2 were supposed to be the same as those inserted into cuss1.

  • Second Insert Statement will give 1 count as the Primary Key is there on CID. At the time of insertion, It will only insert the first record, for second and third it will throw error....

  • 440692 I am just a number (9/14/2011)


    Thanks, good question.

    It nicely highlights the difference between the two insert statements.

    I appreciate the time & effort you took with the question

    Really, its a very good question and nice way of representation.

    Thanks
    Vinay Kumar
    -----------------------------------------------------------------
    Keep Learning - Keep Growing !!!

  • Hi,

    where're correct answers? 😉

    Tx

  • I agree that it's a great question and I thank the author for it but could you please correct the code and allow us to answer it again? Maybe you could change it a little to have different answers? 🙂

    Best regards,

    Best regards,

    Andre Guerreiro Neto

    Database Analyst
    http://www.softplan.com.br
    MCITPx1/MCTSx2/MCSE/MCSA

  • I believe that the second select statement will return 1 instead of 0 or 2.

  • Awesome question.

    And TIA for the points back :-D.

    Notice how I'm definitely not throwing the first stone here 😛

  • bitbucket-25253 (9/13/2011)


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

    Ron

    So this sig was written 2 years ago for specifically this moment. Nice forethought :hehe:

  • The second select doesn't return 2... It returns 1.

    What is it???

  • I selected the right answers even though it was wrong. The second select returns 1 row, not 2.

    http://brittcluff.blogspot.com/

  • Lady Di (9/14/2011)


    The second select doesn't return... It returns 1.

    What is it???

    Yes it does. I'm guessing the PK sequence is wrong in the 2nd insert series, hence the incorrect correct answer selected. Or the correctly incorrect answer to a grammatically correct question. or

    /stackoverflow

  • The second select doesn't return 2... It returns 1.

    What is it???

  • Lady Di (9/14/2011)


    The second select doesn't return 2... It returns 1.

    What is it???

    There's a small typo in the question. Happens sometimes.

    Steve will awards points back whenever he gets up this morning.

Viewing 15 posts - 16 through 30 (of 122 total)

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