June 9, 2015 at 9:37 pm
Comments posted to this topic are about the item Insert without a PK
June 9, 2015 at 10:12 pm
I have to say that this is one of the weirdest set of answers I've ever seen. This is the reason why I don't take certification tests. π
I certainly don't see anything that would disable the indexes in any of the scripts.
Maybe it's just me or the caffeine is wearing off for the day but I don't believe there's actually a correct answer posted as they are currently written.
If the word "NOT" was included before the word "disabled" in the second answer, it would be correct if n changes were made to the code. Like I said, either something is missing in the code or the answers are out in left field.
In the meantime, I'm not going to try to answer this question. π
--Jeff Moden
Change is inevitable... Change for the better is not.
June 9, 2015 at 11:18 pm
Agree, cant say i found any logic in answers vs question script π
June 10, 2015 at 12:53 am
After running the first script the table has 2 indexes, A unique non-clustered on SalesId (PRIMARY KEY) and a clustered on SalesId.
The first insert inserts one row, the second fail on the PK index.
As all the answers are not totally correct, I took what looked to me as the most correct (the second insert produces a PK violation).
My 2 points please...
Louis.
(SQL-Version : 2008 R2)
June 10, 2015 at 12:56 am
For me the first insert worked, and the second failed with a constraint error. However my indexes were not disabled.
So I choose the most matching answer, but that was incorrect. I still think it was more correct than the "correct answer".
Am I missing something?!
June 10, 2015 at 1:12 am
As the others have said, I ran the scripts and, as expected, I got an error about the violation of the primary key constraint. I couldn't see anything about disabling indexes in the question so I went with the answer I'd found to be most right which turned out to be wrong.
How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537
June 10, 2015 at 1:22 am
As the others have said, I ran the scripts and, as expected, I got an error about the violation of the primary key constraint. I couldn't see anything about disabling indexes in the question so I went with the answer I'd found to be most right which is marked as wrong.
June 10, 2015 at 1:32 am
In my personal opinion there is missing that part that should disable the PK ... author probably mentioned to put it before those two insert however he didn't.
June 10, 2015 at 1:32 am
I thought that this statement was missing:
alter INDEX SalesArchive_CI_SalesPersonID ON dbo.SalesArchive disable
... and got it right!
π
June 10, 2015 at 2:32 am
There is nothing in the question that suggests the PK is disabled, so I couldn't see any sensible answer. Went with the one where the first insert succeeds and the second fails. The question needs reviewing. :ermm:
June 10, 2015 at 2:33 am
The answers only make any sense if there is a missing line that disables the primary key, so I answered on this assumption and got it right π
Unfortunately, everyone else who got it wrong will eventually be given points anyway when the question is corrected!
June 10, 2015 at 3:53 am
The QotD from June 8 includes the disabling of indexes. That part of the code was not pasted into this QotD, so like many already mentioned, neither of the answers are correct.
Sql Server blog: http://www.tsql.nu
June 10, 2015 at 3:54 am
None of them are correct, but 1, 2 and 4 are either the least incorrect or could be correct if you assume something's missing in the question. But I don't think anyone who chose 'Both rows are inserted' should get any points back(!?).
June 10, 2015 at 4:41 am
Nicholas Cross (6/10/2015)
There is nothing in the question that suggests the PK is disabled, so I couldn't see any sensible answer. Went with the one where the first insert succeeds and the second fails. The question needs reviewing. :ermm:
+1
June 10, 2015 at 4:48 am
I know I haven't had my coffee yet but there's a problem with the scripts as shown π
Viewing 15 posts - 1 through 15 (of 61 total)
You must be logged in to reply to this topic. Login to reply