Where's the error?

  • Comments posted to this topic are about the item Where's the error?

  • This was removed by the editor as SPAM

  • Bit too easy that one Steve, but good not to have to use the brain this early in the day.

    Thanks

  • Dang, I did not think my first thought was correct so chose the wrong one. If I just would have went with my first...

  • Good Question, I took the obvious answer, but because it was QOD, I was expecting a "got ya".

  • It was different than recent questions and got my brain moving before caffeine. Thanks.

  • I failed to apply the fundamental rule: engage brain before finalizing choice - - I was so happy at spotting that WITH CHECK OPTION would guarantee failure if the update actually did update a row in the view that (a) I didn't notice that the column being updated wasn't actually in the view so it couldn't be updated through the view and (b) even if the column had been in the view, if CHECK OPTION were the only source of failure the where clause might ensure that CHECK OPTION had no rows to check so a CHECK OPTION error couldn't be the answer. :blush:

    Tom

  • In our shop we only use views to retrieve data, not update it.

  • BillLudlow (8/31/2016)


    Bit too easy that one Steve, but good not to have to use the brain this early in the day.

    Thanks

    As of now, only 47% percent of respondents got the correct answer, so apparently it isn't "too easy".

    (;

  • Kaye Cahs (8/31/2016)


    BillLudlow (8/31/2016)


    Bit too easy that one Steve, but good not to have to use the brain this early in the day.

    Thanks

    As of now, only 47% percent of respondents got the correct answer, so apparently it isn't "too easy".

    (;

    Don't forget that people can get things wrong just because they are too easy - remember Poe's purloined letter. 😎

    Edgar Allan Poe (1845)


    "Perhaps it is the very simplicity of the thing which puts you at fault," said my friend.

    "What nonsense you do talk!" replied the Prefect, laughing heartily.

    "Perhaps the mystery is a little too plain," said Dupin.

    "Oh, good heavens! who ever heard of such an idea?"

    "A little too self-evident."

    Tom

  • There were so many possible problems with the view and the update, that I concentrated in the wrong one.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • I didn't have it easy, but I learned something new, thanks Steve.

    Qotd from 2016/08/31 was brilliant, because all the first three answers were right... 😉

    The first error was, that the HireDate was not in the definition of the view NewEmployees.

    If HireDate was added to the definition, an error occurred while converting date '20150230'.

    After the repair to the '20150228' was finally the third error, which is interestingly specified:

    "The attempted insert or update failed because the target view either specifies WITH CHECK OPTION

    or spans a view that specifies WITH CHECK OPTION and one or more rows resulting from the operation

    did not qualify under the CHECK OPTION constraint. The statement has been terminated."

    A good explanation is at https://www.sqlservercentral.com/articles/Stairway+Series/107120/

  • Grrrrr.... Good question. My snap judgment was wrong, and in hindsight it's easy to see why. One day I will learn to consider everything that's in the example before picking an answer. Happy to see Tom's comments, though. At least I feel I'm in good company.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Easy one, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 14 posts - 1 through 13 (of 13 total)

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