January 29, 2010 at 3:14 am
I also checked it on 2005 and the result is 1,1
how it can be 0, 1.
Can somebody explain?
January 29, 2010 at 3:16 am
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
January 29, 2010 at 3:17 am
Set NOCOUNT ON
select @@ROWCOUNT
select @@ROWCOUNT
This will return 0,1 (at least on my 2005 server)
January 29, 2010 at 3:19 am
but without SET NOCOUNT ON/OFF or PRINT it will return (1,1)
January 29, 2010 at 3:30 am
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
January 29, 2010 at 3:30 am
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.
January 29, 2010 at 3:35 am
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.
January 29, 2010 at 3:41 am
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?
January 29, 2010 at 3:55 am
Hi All,
While executing this I am getting 1,1 . Explanation?
January 29, 2010 at 4:08 am
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
January 29, 2010 at 4:36 am
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).
January 29, 2010 at 5:01 am
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.
January 29, 2010 at 5:17 am
The requirements for this questions don't seem to support the given answer. Upon reading the question, my initial reaction was that the results would be 0,1.
Upon opening a new query window and executing the code, I received the results 1,1. If the code was dependent on having set NOCOUNT ON, then that should have been specified in the requirements.
This is one of the most common problems I have seen in development efforts. Poor, or lacking, requirements will result in unexpected results.
January 29, 2010 at 5:34 am
I also tested the code and got 1,1.
So I would have had the wrong answer even testing the code?
What is that Question good for if there are multiple result?
January 29, 2010 at 5:40 am
Another QOTD where either the answer is "It depends" and/or inadequate information is given. I knew that the answer was (x,1) but there's not enough information to determine x. If my previous query had been "select * from sys.databases" then x will probably be a number larger than one. If it had been "select * from sys.databases where 0 = 1" then x is zero. If a new query window is opened then it depends on the tool (SSMS, Query Analyzer...).
Viewing 15 posts - 46 through 60 (of 130 total)
You must be logged in to reply to this topic. Login to reply