What will be the output message?

  • Comments posted to this topic are about the item What will be the output message?

  • Nice question.

    The original INSERT statement misses one quote though.

    But I figured out this was a typo and it had no influence on the answer. 😎

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

  • You're right, Koen.

  • Koen Verbeeck (12/3/2014)


    Nice question.

    The original INSERT statement misses one quote though.

    But I figured out this was a typo and it had no influence on the answer. 😎

    Regardless to it being a typo or not the answer is still the same 🙂 only the error message is different

  • And if the first script is run together as a single batch, the table won't be created and the error message will be something else again!

  • This was removed by the editor as SPAM

  • Yeah, I saw the quote and found myself wondering if that was the trick. Then I saw what ended up being the answer and figured either way, the answer would be the same. Thanks.

  • I wonder if the missing quote was intentional, just to make us think harder, or an error.

    The sarted out by thinking that we are told the table holds that data - so presumably we are to assume that although the insert statement we we are shown couldn't work (and there would be no table created, given how the code is presented) the table does exist and the data shown is what it holds (so the actual insert statement used to create it didn't have a missing quote). So I ignored all that and looked at the select. There is no filter in the select, and no distinct; therefor it either returns the same number of rows as in its source (4) or produces an error message. Is the select statement sound? No, it tries to use LEN on a text column - so it will produce an error.

    But as others have pointed out, if we assume instead that the table creation and poulation use teh bathch shown in the question, so that the table doesn't exist, trying to select from it will produce an error anyway - so whether the missing quote is a real error or a red herring doesn't matter, what the final select produces is an error message either way.

    Tom

  • Though the missing quote mark (which is most probably a typo); the question iteself is good, didn`t know that LEN fn doesn`t work with text data type (which I am not using anyway), good to know new things.

    Many thanx.

    Hany

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Thanks for the great question.



    Everything is awesome!

  • Koen Verbeeck (12/3/2014)


    Nice question.

    The original INSERT statement misses one quote though.

    But I figured out this was a typo and it had no influence on the answer. 😎

    +1

  • Good question, good explanation. Thanks!

  • Hany Helmy (12/3/2014)


    Though the missing quote mark (which is most probably a typo

    Not so much a typo, as forgetting to edit the text when it was copied and pasted from Wikipedia...

  • Is it really that hard to test the code out once before hitting submit?

  • Koen Verbeeck (12/3/2014)


    Nice question.

    The original INSERT statement misses one quote though.

    But I figured out this was a typo and it had no influence on the answer. 😎

    That's what I did as well. After that, it was straight forward.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

Viewing 15 posts - 1 through 15 (of 20 total)

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