Rowcount

  • The "correct" answer is wrong. Results are 1,1.

  • Ummm . . . NO!!! :angry:

    I got 1,1.

    I'm running SQL 2008.

    I want my point.

    +--------------------------------------------------------------------------------------+
    Check out my blog at https://pianorayk.wordpress.com/

  • Of course the real answer should be "it depends", but if you read the question and take it literally, meaning these two statements are all you are running in a new window, then 1, 1 is the correct answer. Any other answer depends on criteria that is not included in the question, such as executing NOCOUNT, having previously executed other commands, etc.

  • Irish Flyer (1/29/2010)


    When you open a new query window, an immediate @@ROWCOUNT will always return a 1. This is an incorrect return

    Sorry to split hairs, but I disagree that it is an incorrect return - there is a reason why it returns 1. 🙂

  • Simon Liddle (1/29/2010)


    Irish Flyer (1/29/2010)


    When you open a new query window, an immediate @@ROWCOUNT will always return a 1. This is an incorrect return

    Sorry to split hairs, but I disagree that it is an incorrect return - there is a reason why it returns 1. 🙂

    Sorry, that was a bit pedantic. Of course there is a reason. I just don't consider it to be the product of sound reasoning.

  • malleswarareddy_m The question is improper

    Rick-153145 Another rubbish QoTD.

    bluesbiker I agree with user "malleswarareddy_m", this question is improper

    To malleswarareddy_m, Rick-153145 and bluesbiker let me issue you a challenge.

    Each of you submit a QOD and lets see how well you do

    [/size]

    I agree with:

    kaspencer So, if you are considering writing a QotD, just remember: you are under a definite obligation to ensure that the answer is predictable and will be produced on the vast majority of instances and versions (unless conditions are specifically mentioned).

    Having submitted 25 QODs, 22 of which have been published, 2 are scheduled for March and 1 pending let me state "It is not an easy task"

    I would add to kaspencer's statement, the following addition: test, test and test again your proposed submission before submitting. Let a few days pass and retest, retest and retest to discover, if any, assumptions or unforseen events that might influence the correct answer(s)

    With all that said and done, the QOD did fullfill one prime goal -- It taught a lot of people something they did not know before.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • I got 1,1 in sql server 2005 EE and SE sp3 and 2008 EE sp1.

    But when tried in sql server 2000 EE sp4 I get 1,0. Question should be specific about the version it is asked for ! !

    My point please :hehe:

    SQL DBA.

  • If one has to connect first in order to to run the t-sql statements, the correct answer should be 1,1. If a theoretical question is being asked with no connection, the answer is 0,1. The wording of the question implies that a connection be made first (use of the word output). I've tried this in versions 2000, 2005 and 2008 (after connecting) and get 1,1 in each case. Geez, maybe we need a legal opinion on this ...

  • I would add to kaspencer's statement, the following addition: test, test and test again your proposed submission before submitting. Let a few days pass and retest, retest and retest to discover, if any, assumptions or unforseen events that might influence the correct answer(s)

    With all that said and done, the QOD did fullfill one prime goal -- It taught a lot of people something they did not know before.

    Bitbucket, you are right, we all learned something. Don't know where I would ever use SELECT @@ROWCOUNT as the first statement of a batch, but who knows... 🙂

    Nevertheless, the question was misleading, and I understand the risen anger as well. So what I learned best was to be very, very, very, very,... careful in case I should ever publish a QotD myself.

    TO all SSC bashers:

    Asking SSC's operators to check each and every question or even to blame them for bad ones is not fair, we must be grateful for the excellent platform they provide to us. You can't ask for more. So what remains is to ask authors to be more careful. We have seen too many bad examples in the recent past.

    And yes, I also want my point back! 😉

    Best regards,
    Dietmar Weickert.

  • Sorry, but I get 1,1

  • Sorry, but I get 1,1

  • bitbucket-25253 (1/29/2010)


    I would add to kaspencer's statement, the following addition: test, test and test again your proposed submission before submitting. Let a few days pass and retest, retest and retest to discover, if any, assumptions or unforseen events that might influence the correct answer(s)

    With all that said and done, the QOD did fullfill one prime goal -- It taught a lot of people something they did not know before.

    You are right. This is professional.

    As in one of editorials several days ago (not verbatim): If you are helping others you improve yourself. Great truth.



    See, understand, learn, try, use efficient
    © Dr.Plch

  • The question seems incomplete. I also got 1,1.

    Simone
  • I definitely want my points for the 1,1 answer.

    NOCOUNT is off by default. If NOCOUNT is set ON you may get 0 first, otherwise, by default you get 1 first.

  • danemery (1/29/2010)


    If one has to connect first in order to to run the t-sql statements, the correct answer should be 1,1. If a theoretical question is being asked with no connection, the answer is 0,1. The wording of the question implies that a connection be made first (use of the word output). I've tried this in versions 2000, 2005 and 2008 (after connecting) and get 1,1 in each case. Geez, maybe we need a legal opinion on this ...

    The connection itself doesn't change the rowcount, it's initialy realy zero. The rowcount is affected only by the statements sent from ManagementStudio (try Profiler). That's not the same.



    See, understand, learn, try, use efficient
    © Dr.Plch

Viewing 15 posts - 76 through 90 (of 132 total)

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