wildcards

  • How many results are returned from this batch?

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

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

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

    SELECT mychar

    FROM @i

    WHERE mychar LIKE 'Ste[^p]%'

    Ans:-

    Above Question it is giving error ,

    if we change varchar(10) to varchar(12) then we can get 2 records as output.

  • Let Me Know if i am wrong:-)

  • Raghavendra Mudugal (9/11/2013)


    Toreador

    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. πŸ™‚

    Dear, the answer is WRONG! are you following the posts here?

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Despite the question having the wrong answer due to an error, I did learn something new about the ^.

    A lot of the questions on here will never be used in practice but this could be. Thanks πŸ™‚

  • Hany Helmy (9/11/2013)


    Raghavendra Mudugal (9/11/2013)


    Toreador

    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. πŸ™‚

    Dear, the answer is WRONG! are you following the posts here?

    Are you reading all my replies properly?

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

  • Hany Helmy (9/11/2013)


    Raghavendra Mudugal (9/11/2013)


    Toreador

    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. πŸ™‚

    Dear, the answer is WRONG! are you following the posts here?

    As Tom pointed out above, the last five or so questions have had errors which have made the choice of answer something of a lottery. But it's a game, it's not important enough to get upset over.

    β€œ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

  • kapil_kk (9/10/2013)


    Danny Ocean (9/10/2013)


    handkot (9/10/2013)


    I got an error: "String or binary data would be truncated. The statement has been terminated."

    (0 row(s) affected);-)

    Just because of "Steppenwolf" having length 11. So insert statement is not executed successfully.

    Correct answer should be "0".

    :crazy:

    I think, nobody check this question before post on SSC. This question is completely wrong.

    Still i didn't believe that this question is posted by "Steve Jones - SSC Editor". :w00t:

    +1

    Totally agree:w00t:

    +1

  • 'Steppenwolf' is 11 characters so having declared the table as

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

    the insert will return an error.

    The right answer should be 0!!

  • In SS2k you must use in T-SQL script this version:

    INSERT @i VALUES ('Steve')

    INSERT @i VALUES ('Stephan')

    INSERT @i VALUES ('Stephanie')

    INSERT @i VALUES ('Sterling')

    INSERT @i VALUES ('Steppenwolf')

    Then are 4 rows in the table @i inserted and correct answer is 2.

  • Ahh! Too many posts and none adding any value to the topic of discussion.

    Wrong question or not, if it was able to teach you something new or refresh your memory about things you knew but had forgotten then it's worth it.

    Go write your own QoTD and share knowledge with everyone.

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

    +1.

    Anyway I understand people complaining as these things should be specified in the body of the question (like the other day with the garbage collector for FILESTREAM only in SQL2012 eg)

    Thanks for the question though.

  • ksatpute123 (9/11/2013)


    Ahh! Too many posts and none adding any value to the topic of discussion.

    Wrong question or not, if it was able to teach you something new or refresh your memory about things you knew but had forgotten then it's worth it.

    Go write your own QoTD and share knowledge with everyone.

    Some of us do that, and we screw things up from time to time; but something as blatantly wrong as today's question, or Monday's, is pretty rare.

    The good thing to remember though, and this is why people shouldn't get too het up about today's question, is that an error as blatant as this will be fixed quite quickly: quite soon, probably by tomorrow, the question will have been changed to specify a greater length for the column so that the answer 2 really is correct; and probably everyone who has answered "incorrectly" up until that point will be given a point, so that no-one will have any grounds to feel they've been cheated of a point (as if that mattered).

    Tom

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

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

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

    SELECT mychar

    FROM @i

    WHERE mychar LIKE 'Ste[^p]%'

    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

    I disagree with the result being "2", by the fact that at the time of the insert generate an error occurs

    "String or binary data would be truncated.", The last name 'Steppenwolf' exceeds 10 characters

  • I actually saw the 11 characters in the last value and answered 0. When I got it wrong and read the explanation, I had to run it because I couldn't see what I missed. Turns out I didn't miss anything.

    It looks like this was a simple mistake in what was marked as the correct answer. We all make mistakes.

  • Vobr Jiri (9/11/2013)


    In SS2k you must use in T-SQL script this version:

    INSERT @i VALUES ('Steve')

    INSERT @i VALUES ('Stephan')

    INSERT @i VALUES ('Stephanie')

    INSERT @i VALUES ('Sterling')

    INSERT @i VALUES ('Steppenwolf')

    Then are 4 rows in the table @i inserted and correct answer is 2.

    SQL Server 2000 is no longer considered as a possible edition in the Questions.

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

Viewing 15 posts - 46 through 60 (of 145 total)

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