That case filter

  • OCTom (7/20/2011)


    😛

    It's good to know that even those will guru-like SQL Server knowledge make these types of mistakes. 😛

    This has happened to me (not this EXACT scenario) before. After looking at code for a period of time, taking a break, and coming back, the problem seems to jump out at me. Another method to get unstuck is to have someone else look at the code. I even have people who know nothing about SQL or development look at code and their perspective is sometimes valuable.

    Thanks for the question and the humorous (at least to me) story behind it. All I can say is "been there; done that."

    We know about this issue but we still felt it was the best way to present the question.

    Thanks for sharing your concerns.

  • Toreador (7/20/2011)


    BenWard (7/20/2011)

    it affected 5 rows.

    or perhaps

    it returned "5 rows"

    😉

    Please Define "returned". :w00t:

  • Ninja's_RGR'us (7/20/2011)


    Toreador (7/20/2011)


    BenWard (7/20/2011)

    it affected 5 rows.

    or perhaps

    it returned "5 rows"

    😉

    Please Define "returned". :w00t:

    Also affected might be too strong of a word here... no rows in datapages were ever affected here!

  • Poorly worded question that has nothing to do with the the subject in the title and with none of the possible answers matching what actually happens in practice.

    Other than that - well done!;-)

  • BenWard (7/20/2011)


    Toreador (7/20/2011)


    BenWard (7/20/2011)


    don't forget, if this question - or it's answer - was actually wrong it wouldn't have been published.

    Sadly that's not the case. There have been many recent questions with minor typos, how were we to know that this wasn't another?

    oh well I thought they were read over by the good people who run this place first.

    It would appear that people are trying to overcomplicate the question:

    "0 seems like a silly answer therefore I will assume the OP meant something entirely different from what he actually asked and answer accordingly... What? My answer was wrong? Don't be silly the questin was wrong!"

    🙂

    In management studio a query often outputs to 2 tabs, Messages and Results.

    If anything is RETURNED by a query it goes in Results.

    If anything is PRINTED by a query it goes to Messages.

    '(5 rows affected)' comes up in Messages and there is no 'Results' tab. There is no results tab because there were no results, logically, 0 rows have been returned by the query batch.

    If you're going to be pedantic, then please be *pedantic*:

    "No Results" <> 0 rows

    "No Results" is null rows

    This question is hopelessly worded and should be withdrawn

  • Dah, thanks Ben. Sorry about that. What he was doing was passing in the condition through a variable. Here is the refined example.

    declare @Foo as char(10), @comparerChar as char(10), @comparerVarChar as varchar(10)

    set @Foo = 'BoopyBoppy'

    set @comparerChar = 'Bo%'

    set @comparerVarChar = 'Bo%'

    if @Foo like @comparerChar

    select 'yay char'

    if @Foo like @comparerVarChar

    select 'yay varchar'

  • Ninja's_RGR'us (7/20/2011)

    --------------------------------------------------------------------------------

    Ninja's_RGR'us (7/20/2011)

    --------------------------------------------------------------------------------

    Toreador (7/20/2011)

    --------------------------------------------------------------------------------

    BenWard (7/20/2011)

    it affected 5 rows.

    or perhaps

    it returned "5 rows"

    Please Define "returned".

    Also affected might be too strong of a word here... no rows in datapages were ever affected here!

    Excuse me for having a typo! I thought we were all on the same team here? I was talking about perception not redefining words.:hehe:

    :cool:

    "There are no problems! Only solutions that have yet to be discovered!"

  • jcunningham (7/20/2011)


    Dah, thanks Ben. Sorry about that. What he was doing was passing in the condition through a variable. Here is the refined example.

    declare @Foo as char(10), @comparerChar as char(10), @comparerVarChar as varchar(10)

    set @Foo = 'BoopyBoppy'

    set @comparerChar = 'Bo%'

    set @comparerVarChar = 'Bo%'

    if @Foo like @comparerChar

    select 'yay char'

    if @Foo like @comparerVarChar

    select 'yay varchar'

    Ya that makes more sense. Thanks for the update!

  • I would just like to say thankyou.

    I had a streak of 5 questions being missed and then yesterday I got one right.

    Today I got one wrong again, the streak starts over.

    But very inventive.:cool:

  • bopeavy (7/20/2011)


    Ninja's_RGR'us (7/20/2011)

    --------------------------------------------------------------------------------

    Ninja's_RGR'us (7/20/2011)

    --------------------------------------------------------------------------------

    Toreador (7/20/2011)

    --------------------------------------------------------------------------------

    BenWard (7/20/2011)

    it affected 5 rows.

    or perhaps

    it returned "5 rows"

    Please Define "returned".

    Also affected might be too strong of a word here... no rows in datapages were ever affected here!

    Excuse me for having a typo! I thought we were all on the same team here? I was talking about perception not redefining words.:hehe:

    No excuses necessary. I was worried about that in the question as well. If your understanding of the word returned was wrong, then only a guess or running the code could give you the correct answer. Unfortunately this was out of my control.

  • jwbart06 (7/20/2011)


    I would just like to say thankyou.

    I had a streak of 5 questions being missed and then yesterday I got one right.

    Today I got one wrong again, the streak starts over.

    But very inventive.:cool:

    That's the spirit :w00t:.

    Thanx for the good laugh :hehe:.

  • roger.plowman (7/20/2011)


    BenWard (7/20/2011)


    Toreador (7/20/2011)


    BenWard (7/20/2011)


    don't forget, if this question - or it's answer - was actually wrong it wouldn't have been published.

    Sadly that's not the case. There have been many recent questions with minor typos, how were we to know that this wasn't another?

    oh well I thought they were read over by the good people who run this place first.

    It would appear that people are trying to overcomplicate the question:

    "0 seems like a silly answer therefore I will assume the OP meant something entirely different from what he actually asked and answer accordingly... What? My answer was wrong? Don't be silly the questin was wrong!"

    🙂

    In management studio a query often outputs to 2 tabs, Messages and Results.

    If anything is RETURNED by a query it goes in Results.

    If anything is PRINTED by a query it goes to Messages.

    '(5 rows affected)' comes up in Messages and there is no 'Results' tab. There is no results tab because there were no results, logically, 0 rows have been returned by the query batch.

    If you're going to be pedantic, then please be *pedantic*:

    "No Results" <> 0 rows

    "No Results" is null rows

    This question is hopelessly worded and should be withdrawn

    Let's not start a null war again, that discussion's been beaten to death already.

    Thank you.

  • Spotted the Extra Union All a mile away.

    Got the answer right, but never read the question title.

    Had I read the question title I would been like the 50% of those that corrected the UNION ALL and concentrated on the question content.

    Thinking that the Question submission process had caused us to have some bad SQL that was not intended, once again, as always.

    All I will say is this:

    When your question has almost 8 pages of posts before 8:00 AM CDT, you should seriously re-think what you where doing.

    It seems from the posts that you might have?

  • I notice the mistake, but since that has been common in the QoTD I took it just as that a mistake... tough question, set's a dangerous precedence of having to realize if the mistake is intentional or not.

    I don't know what I learned from the QoTD today. Be anal Retentive, maybe?

  • I believe Ninja's_RGR'us has to defend his question, if nothing was said then I would question it.

    Points are points, I keep going through old questions and see mistakes, I don't believe this was a mistake.

    8 pages later.

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

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