What will be the output message?

  • ksatpute123

    Hall of Fame

    Points: 3325

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

  • Koen Verbeeck

    SSC Guru

    Points: 258965

    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

  • Mauricio_

    SSCrazy

    Points: 2931

    You're right, Koen.

  • Emil B

    SSCertifiable

    Points: 5568

    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

  • Toreador

    SSChampion

    Points: 11261

    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

  • Ed Wagner

    SSC Guru

    Points: 286985

    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.

  • TomThomson

    SSC Guru

    Points: 104773

    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

  • Hany Helmy

    SSChampion

    Points: 13488

    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

  • Dana Medley

    SSCertifiable

    Points: 6764

    Thanks for the great question.



    Everything is awesome!

  • RK Mandava

    SSCarpal Tunnel

    Points: 4153

    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

  • cgumprich

    SSC Eights!

    Points: 857

    Good question, good explanation. Thanks!

  • Toreador

    SSChampion

    Points: 11261

    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...

  • ZZartin

    SSC-Dedicated

    Points: 30420

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

  • SQLRNNR

    SSC Guru

    Points: 281252

    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 21 total)

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