wildcards

  • Toreador (9/11/2013)


    Koen Verbeeck (9/11/2013)


    Indeed. As if I'm going to count the number of characters in Steppenwolf.

    Why wouldn't you? I did, and got it wrong as a result.

    I was guessing though, as I didn't know whether the invalid value would prevent all the others being inserted or not.

    Exactly what I was saying! what`s the problem of counting the characters of a value?! and what`s the problem of being Accurate to get the correct answer?!

    And by the way, why Steve didn`t reply to all these posts until now?! maybe he's busy with something!

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Nice question.

    Results are very obvious.

    It needs

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

    Igor Micev,My blog: www.igormicev.com

  • Koen Verbeeck (9/11/2013)

    Indeed. As if I'm going to count the number of characters in Steppenwolf.

    Why not? I did, because I immediately thought the word looked too long for a 10-character field, and when I totalled it up to 11, I thought "Aha! Sneaky trick question time!" and put 0 in. Was very surprised when the question claimed the answer to be 2, so I went and ran the script and got exactly the same result; no rows inserted due to the error, so no results returned. Maybe it's a bit of a Pavlov reaction to be looking for tricks where there were apparently intended to be none, due to getting burned by that on so many QotDs in the past; still, doesn't stop this being a poor question because it demonstrably does not return the answer specified.

    (Heck, if the question is just asking about pattern matching, it didn't even need to use a script--Steve could have listed the strings and asked, "How many of these does the pattern 'Ste[^p]%' match?").

  • If you oversight the 11 Character (Binary Data truncated issue), otherwise good question to learn something new.

  • paul.knibbs (9/11/2013)

    Why not? I did, because I immediately thought the word looked too long for a 10-character field, and when I totalled it up to 11, and put 0 in. Was very surprised when the question claimed the answer to be 2, so I went and ran the script and got exactly the same result; no rows inserted due to the error, so no results returned. doesn't stop this being a poor question because it demonstrably does not return the answer specified.

    Same steps I did,

    Totally agree it`s a poor question (not nice @ all like some here said) as the answer is wrong & not explained well.

    The only thing could made this question nice & correct if it was mentioned in the beginning:

    Set Ansi_Warnings off;

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Come on guys, it's pretty obvious what the point of the question was and knocking the last letter off of 'Steppenwolf' makes everything work as the OP intended.

    If you're worried because you "lost a point" because the code failed when you ran it bear in mind that the point of QOTD is to make you think a bit. Anybody can actually run the code to get the (normally) right answer - it means nothing. As all you need to do to get a point is write a post containing "+1" every day (which at least one person does) they're not exactly hard to come by.

    I didn't run the code so actually got it right as I assumed the length thing wasn't a deliberate trap.:-)

  • Good question, Steve. Thank you for posting.

    (Apart from the issue in the string length which can be known when one executes the statement, I just analyzed the question without executing and picked the right answer. Executing the SQL from the qtod is not a proper way for picking the answer, but some complex qtods needs executing, and definitely this one is not, so come on guys..... you all are Pros here. I know most of them here (or all) do not consider my reply as acceptable...but I don't mind, and even this applies to me. πŸ˜‰ )

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • Raghavendra Mudugal (9/11/2013)


    I just analyzed the question without executing and picked the right answer.

    You clearly didn't analyse it very well then πŸ˜‰

  • Toreador (9/11/2013)


    Raghavendra Mudugal (9/11/2013)


    I just analyzed the question without executing and picked the right answer.

    You clearly didn't analyse it very well then πŸ˜‰

    Good one πŸ™‚

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Three out of the last five questions wrong. This is a pretty terrible patch, isn't it. And last Thursday's still not corrected, so it continues to encourage a growing myth.

    Tom

  • paul.knibbs (9/11/2013)


    Koen Verbeeck (9/11/2013)

    Indeed. As if I'm going to count the number of characters in Steppenwolf.

    Why not? I did, because I immediately thought the word looked too long for a 10-character field, and when I totalled it up to 11, I thought "Aha! Sneaky trick question time!" and put 0 in. Was very surprised when the question claimed the answer to be 2, so I went and ran the script and got exactly the same result; no rows inserted due to the error, so no results returned. Maybe it's a bit of a Pavlov reaction to be looking for tricks where there were apparently intended to be none, due to getting burned by that on so many QotDs in the past; still, doesn't stop this being a poor question because it demonstrably does not return the answer specified.

    (Heck, if the question is just asking about pattern matching, it didn't even need to use a script--Steve could have listed the strings and asked, "How many of these does the pattern 'Ste[^p]%' match?").

    First thing I did was check the pattern and get 2; but in doing that I noticed Steppenwolf looked quite long. So I counted the characters, and got 11. I reckoned that 11 was greater than 10, and therefor answered 0. I didn't bother to run the code when that turned out not to be the "correct" answer, what would be the point in doing that? I didn't think that that part of the T-SQL language definition would have suddenly changed while I wasn't looking πŸ˜‰ and it seemed even less likely that 10 had suddenly become greater than or equal to 11 :w00t:. So it was quite clear that the "correct" answer was wrong, yet again.

    Tom

  • Got the error message:

    Msg 8152, Level 16, State 14, Line 3

    String or binary data would be truncated.

    The statement has been terminated.

    (0 row(s) affected)

    πŸ™

  • L' Eomot InversΓ© (9/11/2013)I didn't bother to run the code when that turned out not to be the "correct" answer, what would be the point in doing that?

    I did that because sometimes the QotD is demonstrating a quirk or even bug in SQL server that gives unexpected results--true, the answer didn't say anything along those lines, but I thought I'd best run the script anyway to make sure I wasn't going completely insane. πŸ™‚

  • Toreador (9/11/2013)


    Raghavendra Mudugal (9/11/2013)


    I just analyzed the question without executing and picked the right answer.

    You clearly didn't analyse it very well then πŸ˜‰

    If I didn't then I would never had got the answer correct.. but I did, and this is all it needs for this qtod. πŸ™‚

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • To Err is human .... πŸ™‚

    if one ignore the "String or binary data would be truncated." error .. which i do

    so good question ...

    Just a tiny little advice to author, do the final check on code before posting ... πŸ˜‰

Viewing 15 posts - 31 through 45 (of 145 total)

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