Rowcount

  • I ran the query on SQL 2000 and SQL 2008 and the result was (1,1)

  • It returned 1,1 on SQL 2005

    I want my point back 🙁

  • I also tried it and got 1,1 Another untested question:hehe:

    At least got my point by writing this reply 🙂

  • I also checked it on 2005 and the result is 1,1

    how it can be 0, 1.

    Can somebody explain?

  • If one omits the set nocount on statement, then the results would be 1,1.

    This assert is wrong.

    The correct answer is 0,1, but the two statement should be the first in the connection.

    SSMS or QA on new connection execute some hidden commands (see profiler.exe please).

    SET NOCOUNT OFF

    select @@ROWCOUNT

    select @@ROWCOUNT

    --or

    SET NOCOUNT ON

    select @@ROWCOUNT

    select @@ROWCOUNT

    --or

    print''

    select @@ROWCOUNT

    select @@ROWCOUNT

    return always 0,1 because SET and PRINT don't return RESULTS

  • Set NOCOUNT ON

    select @@ROWCOUNT

    select @@ROWCOUNT

    This will return 0,1 (at least on my 2005 server)

  • but without SET NOCOUNT ON/OFF or PRINT it will return (1,1)

  • Another rubbish QoTD.

    Can I have my point back?

    The result is (1,1). This would be the case no matter what as it is to do with how the question was asked. If it had had SET NOCOUNT ON at the beggining, then the result would be (0,1), but it doesn't.

    Sort your questions out SSC

  • This question is decidedly woolly. Forget all the ifs and maybes about which client to use, which version of SQL or extra commands to include - you won't get far with databases if you can't be precise and the question wasn't.

  • Answering the question from face value, I was going to choose 0,1 as the answer however, checking my logic in SQL 2005 & 2008 and both returned 1,1 as the answer no matter if it was a new window or a previously used window both returned 1,1.

    My initial reasoning was that the first query should run and return no rows because nothing at that point should have returned a value, but the second would return 1 for the previous query.

    Wishing now I had answered from my initial instinct but never mind. 🙂

    Regards
    ld

    Stoke-on-Trent
    United Kingdom

    If at first you don't succeed, go to the pub and drink away your current thought plan.

  • leon_h (1/29/2010)


    My initial reasoning was that the first query should run and return no rows because nothing at that point should have returned a value, but the second would return 1 for the previous query.

    Wishing now I had answered from my initial instinct but never mind. 🙂

    Me too. :unsure: My instincts told me (0,1), but like an idiot I tried it on several servers and got (1,1). So I picked that to be told I was wrong :rolleyes:

    I do think the arguments about SET NOCOUNT are pretty much a moot point since this was not in the original question. Answering the question as it was written gives (1,1), so surely that is the correct one?

  • Hi All,

    While executing this I am getting 1,1 . Explanation?

  • Tested on 3 versions and got...

    SQL 2000 (0,1)

    SQL 2005 (1,1)

    SQL 2008 (1,1)

    I think the question should be re-worded and answers reset if the posts on this discussion are anything to go by... Just my 3 cents worth

    Facts are stubborn things, but statistics are more pliable - Mark Twain
    Carolyn
    SQLServerSpecialists[/url]

  • Hi All,

    I got right answer(0,1) in SQL 2005, but this not in the fresh query window, first I executed pervious question query in query window then I executed this one, now answer is (0,1).

    On the other hand when I read reply on this forums then I realize problem and execute it into the new query window then I got (1,1).

  • I tried it on 3 different servers, and interestingly enough, my SQL 2000 returned 0,1. But with the information available, I agree that 1,1 would be the correct answer.

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

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