• Hugo Kornelis (2/10/2009)


    Either the author of the question wrote this question to educate people about the existance of the IDENTITY() function, in which case SELECT INTO would be the expected answer. Or the author expected the readers to know about this and wrote the question to warn about some less published and less well-known side effects, in which case SELECT INTO would obviously have been wrong and CREATE TABLE ... INSERT SELECT would have been right.

    Since there is no way to read the mind of the author of the question, I was faced with a 50/50 chance of getting my answer right. I took my chance ... and lost.

    And then I took the opportunity to evangelize about those side effects anyway! 😀

    Like Hugo I quickly decided that two answers were just plain wrong, and two would work (or work sort of). One of the two that would work (sort of) would only work in case where it was fair to assume that nothing mattered but the values in the table - defaults and other constraints, indexes, and triggers were irrelevant, because "a copy of the table" actually meant "a copy of the data in the table" and not what it said; the other one would work in all circumstances.

    Given some of the questions and answers I have seen here I reached the opposite conclusion to Hugo - the answer claimed as correct would probably be the sloppy one which would work only in special circumstances, not the one which would always work; so I "won" by choosing the answer which I knew to be wrong.

    Tom