Altering a Column

  • codebyo (4/25/2012)Sorry, guys, for not adding a note on how many answers should be selected.

    Actually, just stating that one or more answers may be correct would be enough. But, in the "real world", does the code tell you how many bugs there are to find?

    "Yep, found all three, code is now completely bug free!"

    I enjoyed not knowing how many there were. Focused my attention more.

    Thanks for a great question!

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • Thomas Abraham (4/25/2012)


    codebyo (4/25/2012)Sorry, guys, for not adding a note on how many answers should be selected.

    Actually, just stating that one or more answers may be correct would be enough. But, in the "real world", does the code tell you how many bugs there are to find?

    "Yep, found all three, code is now completely bug free!"

    I enjoyed not knowing how many there were. Focused my attention more.

    Thanks for a great question!

    I agree with this - it is probably more of a challenge not knowing how many answers to select.

  • Great question. I love these kinds of questions because I always learn something.

    BOL is not always correct, so I've come to not trust it and always test when the answer matters.

    Converting oxygen into carbon dioxide, since 1955.
  • I'm a little confused why 2 isn't allowed. Even on the msdn site it states :

    NOT NULL can be specified in ALTER COLUMN only if the column contains no null values.

    And seeing how the table started out as NOT NULL, and we didn't do any changes to the data in the records between each ALTER shouldn't it have worked?

    EDIT: woops, didn't see the explanation above about having to drop the index.

  • skanker (4/25/2012)


    Thomas Abraham (4/25/2012)


    codebyo (4/25/2012)Sorry, guys, for not adding a note on how many answers should be selected.

    Actually, just stating that one or more answers may be correct would be enough. But, in the "real world", does the code tell you how many bugs there are to find?

    "Yep, found all three, code is now completely bug free!"

    I enjoyed not knowing how many there were. Focused my attention more.

    Thanks for a great question!

    I agree with this - it is probably more of a challenge not knowing how many answers to select.

    +1 I have no issue not being told how many answers to choose. Made me think harder about it.

  • KWymore (4/25/2012)


    I have no issue not being told how many answers to choose.

    My only issue is that since we're nortmally told when more than one answer is needed, I assumed that was the case here and there was therefore only one answer :blush:

  • If you stated the number of correct answers you'd have (in this case) to omit the 'None will fail' teaser...

  • Got me thinking so i only choose 3 and 5 missed 2...Good Question.

    Alex S
  • andrew.ing (4/25/2012)


    If you stated the number of correct answers you'd have (in this case) to omit the 'None will fail' teaser...

    Also, if only one answer was needed then the answer choices would have been set as radio buttons versus check boxes. I suppose you could get tricky and use check boxes and only have one correct answer but I cannot recall seeing a question set up that way yet.

    Now if there had been 10+ potential choices then I agree that a hint towards the correct number of selections may be warranted. It would depend on how similar the answers were or how complicated the question was. However with a hint to choose 3 out of 5 (excluding the none will fail option) you could just do a process of elimination and not really grasp why the 3 would fail, just that you know the other 2 would work. 😉

  • It helps to read the question! Big difference between which command and commandS will fail. I knew item 2 would fail first so I picked that but only that thinking the question was which will fail first.

    Cheers

  • great question - tks

  • Hugo Kornelis (4/25/2012)


    L' Eomot Inversé (4/25/2012)


    BoL


    NOT NULL can be specified in ALTER COLUMN only if the column contains no null values

    this is a bit unfortunate. I haven't tested with 2012 (must acquire a platform that will run 2012) and I suspect that this is an error on that BoL page.

    No, I don't think so (though I have not tested either). As far as I know, this is accurate - for unindexed columns.

    Perhaps I should have given the context: if you look at the full BoL paragraph

    NULL can be specified in ALTER COLUMN to force a NOT NULL column to allow null values, except for columns in PRIMARY KEY constraints. NOT NULL can be specified in ALTER COLUMN only if the column contains no null values. The null values must be updated to some value before the ALTER COLUMN NOT NULL is allowed, for example:

    the reference to a primary key constraint in the first sentence seems to me to indicate that the paragraph applies when an index exists except when the contrary is specified (as for the case considered in the first sentence). If the paragraph applied only to unindexed columns there would be no need to mention the exclusion of columns in primary key constraints.

    Hugo Kornelis (4/25/2012)


    The actual error in Books Online is here:

    The modified column cannot be any one of the following:

    (...)

    Used in an index, unless the column is a varchar, nvarchar, or varbinary data type, the data type is not changed, the new size is equal to or larger than the old size, and the index is not the result of a PRIMARY KEY constraint.

    This quote suggests that ANY change of nullability is prohibited if the column is indexed.

    yes, if you consider NULL/NOT NULL as part of the type; on this page it appears not to be treated as part of the type, since the section on NULL/NOT NULL further down the page merrily talks about allowing changes without any constraint on whether there is an index. Anyway, if the nullability is considered as part of the type then the section you quoted and the section I quoted (which makes no mention of indexes except indirectly when it mentions primary key constraints) are mutually contradictory and (on my reading of the plain meaning of the latter paragraph they would then both be wrong).

    Tom

  • 10 minutes of head scratching... Thanks for stimulation question, Andre!

  • "Choose your answer" means one answer in the English language.

  • Dang it. I missed the (s) in commands that will fail. I just pick one. Good question though.

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

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