Rowcount

  • honza.mf (1/29/2010)


    And what about the answer "Any number, 1" or better "Nonnegative number, 1".

    Agreed 😎

  • It seems to depend on the client tool, not the server - I tried this with both QA and SSMS against a SQL 2000 server - QA returned 1,0 as per the "correct" answer, SSMS returned 1,1.

    I answered before trying the script and got it right, tried the script in QA and saw that agreed, but only tried SSMS after reading the discussion.

    As to suggestions about trying against different versions, bear in mind that the question might have been contributed by someone without easy access to anything above 2000 or may have been submitted a long time ago. In fact, I would never have fired up SSMS to test against my 2000 Server if it hadn't been for the discussion that came about because the answer was ambiguous! 😛

  • I have tried this on a few severs now and on a few different version and still get 1,1

    Is this right?

  • Got (1,1) on 2000

  • if i do as the question says i get the answer 1,1

    but if i do

    set nocounton

    select @@rowcount

    select @@rowcount

    i then get the answer given

  • Just to take this one step further from my previous comment about it depending on the client tool....

    If you profile QA as you connect to the server, you will see that the last statements executed by QA on opening a new window (connection) are SET statements which configure the connection settings (ansi_nulls, nocount, quoted_identifier, etc.) so @@ROWCOUNT when you have a new blank QA window is 0.

    In contrast, when you profile SSMS, you'll see that the last statements to execute are SELECT statements (in my case, they are capturing my spid and the SQL version). In this case, the @@ROWCOUNT when you have a new blank query window open in SSMS is 1.

  • that is the issue as i ran the queries on SQL2005 std edition

  • I have same experience on few servers - 1,1. It really depends on previous commands and if non commands were run, than it is 1,1, so you should change the correct answer.

  • As the question is currently posted there are two correct answers.

    If you run a statement with no rowcount and then run the query you get (0,1) but if you run the query in a new query window then you get (1,1).

    The sql should have been:

    SET <some option>

    select @@ROWCOUNT

    select @@ROWCOUNT

    Think it must be that establishing a query window causes some operation that sets the @@rowcount to one (insertion of the allocated spidid into the sys tables?). Hence the two answers that people have observed.

  • I got 1,1. Ithink the qod should be more precise.

    Thanks

  • Well, well, well, yet another complaint about a QotD, and I am not the only one!

    Like so many others, I was inclined to go for 0,1 but I just thought I'd run it first to see whether I was right - and yet again someone has asked a question that does not always produce the same result.

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

    And Editors: how about fining the writers of bad questions - demoting them by two ranks eh? That'll teach 'em!

    Kenneth Spencer

    You never know: reading my book: "All about your computer" might just tell you something you never knew!
    lulu.com/kaspencer

  • As to suggestions about trying against different versions, bear in mind that the question might have been contributed by someone without easy access to anything above 2000 or may have been submitted a long time ago.

    Really? Someone without access to anything above 2000? Maybe, but is this enough to submit a valid question? Why not to mention "in SQL 2000" in the heading of the question?

    I'm not sure about the age of questions, but are they older than a year?



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

  • kaspencer (1/29/2010)


    And Editors: how about fining the writers of bad questions - demoting them by two ranks eh? That'll teach 'em!

    And back again: What about trying the script by editors? Yes, it's a work, but isn't it less work compared to reseting points, changing question, changing answer, resubmitting points and other tricks used in similar cases?

    I'm pretty sure editors have access to as many versions of SQL Server as needed.



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

  • This was removed by the editor as SPAM

  • Initially thought it would be (0,1) then I was in dual mind in (0,1) and (1,1) finally I executed in Fresh Query Window in 2008 and got (1,1).

    Amit,

    Can you share your screen shot how you get (0,1). Hope you will not SET NO COUNT ON and then show us the result. 😀

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

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