wildcards

  • The correct answer is 0 since 'steppenwolf' is 11 characters long and would return an error.


    Thanks,

    ToddR

  • isaquedejair (9/11/2013)


    Discordo do resultado ser "2", pelo fato de que no momento de gerar o insert ocorre um erro

    "String or binary data would be truncated.", o ultimo nome 'Steppenwolf' excede 10 caracteres

    É galego ou é portugués?

    Tom

  • Todd Reddinger (9/11/2013)


    The correct answer is 0 since 'steppenwolf' is 11 characters long and would return an error.

    It's amazing that in 7 pages of discussion, you're the first person to point that out 😉

  • LOL...here's my thought process.

    Quick read - looks like it should return 2 rows.

    Hmmm...are 2 rows = 2 results? Not really...it's 1 result.

    Look again...looks like Steppenwolf will cause an error.

    Hmmm...does that mean that it is 1 result (the error) or 0 rows?

    Grrrrr....the subject of the question is "wildcards" so I will assume that the error was an accident and go with my first thought of 2.

    Run the code and go back through the same logic again - same outcome - my answer is 2.

    That's a lot of exercise for a seemingly simple question 🙂

  • batgirl (9/11/2013)


    LOL...here's my thought process.

    Quick read - looks like it should return 2 rows.

    Hmmm...are 2 rows = 2 results? Not really...it's 1 result.

    Look again...looks like Steppenwolf will cause an error.

    Hmmm...does that mean that it is 1 result (the error) or 0 rows?

    Grrrrr....the subject of the question is "wildcards" so I will assume that the error was an accident and go with my first thought of 2.

    Run the code and go back through the same logic again - same outcome - my answer is 2.

    That's a lot of exercise for a seemingly simple question 🙂

    Did you get into a flap? 😛

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • Me too (SQL2008R2).

  • The correct answer should be zero because mychar is only declared as a varchar 10 and Steppenwolf is 11 characters so the result set will return:

    Msg 8152, Level 16, State 14, Line 3

    String or binary data would be truncated.

    The statement has been terminated.

    (0 row(s) affected)

  • Disappointing to get the answer "wrong" when I answered correctly. Were we supposed to assume bugs were fixed, and give our answer based on the correct varchar precision?

  • I am familiar with the wildcard operator and like everyone else, the answer should have been 2, but because of the insert issue, I also chose 0 knowing that the insert statement would fail. The results returned from the batch is zero

    ______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience

  • The last string 'Steppenwolf' is 11 characters long, so the insert would have failed, and hence no rows will be returned by the Select statement. so the answer should be 0

  • Msg 8152, Level 16, State 14, Line 3

    String or binary data would be truncated.

    The statement has been terminated.

    (0 row(s) affected)

    Question Faulty --> I want my point back!!! :w00t:

  • Msg 8152, Level 16, State 14, Line 3

    String or binary data would be truncated.

    The statement has been terminated.

    (0 row(s) affected)

    Question is Faulty => I want my point back :w00t:

  • Dear Steve

    Can you change the points system so that if someone replies pointing out an error and 8 pages of people have already replied pointing out the same error in the same way, then instead of giving them an extra point, they instead have 10 points subtracted?

    Thanks in advance

  • Carlo Romagnano (9/11/2013)


    The correct exceution of the query depends on ansi_warnings

    set ansi_warnings off

    DECLARE @i TABLE( mychar VARCHAR(10));

    INSERT @i VALUES ('Steve'), ('Stephan'), ('Stephanie')

    , ('Sterling'), ('Steppenwolf')

    SELECT mychar

    FROM @i

    WHERE mychar LIKE 'Ste[^p]%'

    It returns two rows in ONE resultset.

    The question asks how many results ...?

    The resultset is only ONE.

    No, there is one resultset with two results in it.

  • Toreador (9/11/2013)


    Dear Steve

    Can you change the points system so that if someone replies pointing out an error and 8 pages of people have already replied pointing out the same error in the same way, then instead of giving them an extra point, they instead have 10 points subtracted?

    Thanks in advance

    How else would they get their point back?

    I've found that the discussions about the QotD are generally more informative than the questions themselves. Mostly because the questions either have an accidental mistake, a purposeful mistake or a poor explanation. Either way I almost always learn something new.

Viewing 15 posts - 61 through 75 (of 145 total)

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