January 29, 2010 at 5:43 am
fallenstudent (1/29/2010)
I also tested the code and got 1,1.So I would have had the wrong answer even testing the code?
Nobody can tell if you would have had the right or wrong answer because it depends on what you use when "testing the code."
January 29, 2010 at 5:53 am
hate to beat a dead horse. but anytime i execute this in a query window it returns 1,1 ... i also thought it would be 0,1 but was intrigued by it so thus i tested it.
January 29, 2010 at 6:02 am
I ran it in a clean window with no previous queries run in SQL 7 & 2005 and they both returned 1,1. Also, the question did not state to run it with nocount on....I rarely turn that option on in a query window because I WANT to see how many are returned.
D
January 29, 2010 at 6:03 am
I agree with user "malleswarareddy_m", this question is improper
January 29, 2010 at 6:18 am
I'm using sql 2008, and as others have stated, if I do SET NOCOUNT ON and then run the queries, I get 0,1. Without it, I get 1,1.
Amu
January 29, 2010 at 6:42 am
Same here.
January 29, 2010 at 6:42 am
amarshall-568002 (1/29/2010)
I'm using sql 2008, and as others have stated, if I do SET NOCOUNT ON and then run the queries, I get 0,1. Without it, I get 1,1.Amu
Yes but that's not what the code in the question says :w00t:.
January 29, 2010 at 6:53 am
While intuitively I expected a result set of (0,1), I must echo what everyone else has said, I also achieved the results set of (1,1) when I tested it for myself.
LinkedIn: https://www.linkedin.com/in/sqlrv
Website: https://www.sqlrv.com
January 29, 2010 at 6:55 am
This might be a interesting question , but i don't think so..coz u should mention the server wheather it is 2k/05/08.As u gave ans 0 ,1 it is correct in 2k but not in 2005. could u please elaborate.so that i'll satisfy...?
Thanks
SUrya
January 29, 2010 at 6:56 am
Since the question asks what the output of
SELECT @@ROWCOUNT
SELECT @@ROWCOUNT
then the answer must be 1,1 or perhaps an answer that was not offered "It depends". No one can reasonably assume that SQL 2000 was being used or that using SET NOCOUNT ON is required to meet the authors objective.
Scott
January 29, 2010 at 7:15 am
I experienced 1,1 also. The ms link provided concerning rowcount had this to say:"Statements that make a simple assignment always set the @@ROWCOUNT value to 1. No rows are sent to the client. Examples of these statements are: SET @local_variable, RETURN, READTEXT, and select without query statements such as SELECT GETDATE() or SELECT 'Generic Text'."
January 29, 2010 at 7:16 am
The answer is absolutely 1,1 because of the way the question was asked. It does not mention anything about a pre-used query window. When you open a new query window, an immediate @@ROWCOUNT will always return a 1. This is an incorrect return, but it is what it is.
January 29, 2010 at 7:16 am
The "correct" answer is wrong. Results are 1,1.
January 29, 2010 at 7:18 am
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/
January 29, 2010 at 7:24 am
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.
Viewing 15 posts - 61 through 75 (of 130 total)
You must be logged in to reply to this topic. Login to reply