June 28, 2010 at 12:14 am
malleswarareddy_m (6/27/2010)
sheik (6/27/2010)
The table should be created with the identity (-1,-1). Then only we can get this result. Must be a typo error???.It's correct.
Right.
Create Table MyTable1( mainkey int not null identity (-1,-1))
GO
insert into MyTable1 default values
insert into MyTable1 default values
insert into MyTable1 default values
Select * from MyTable1
drop table MyTable1
Now this code gives -1,-2,-3
Typing error. Lost my point...
June 28, 2010 at 12:14 am
I think the question is wrong.
incase identity(-1,-1) then the answer ll be correct other wise will get -1,0,1 only.
June 28, 2010 at 12:18 am
ditto
John
June 28, 2010 at 12:22 am
Must be typing mistake from the author of this question... but how can we have "-0" in the result. 😉
June 28, 2010 at 12:23 am
I think this is a typo.I want my point.:crying:
June 28, 2010 at 12:27 am
I am getting -1,0,1 as the final output. Could somebody recheck the answer.
June 28, 2010 at 12:30 am
Interesting that the - got in the wrong place in the question, I saw the "-0" and thought that something might be up, but I picked that option anyhow since no other one was possible. I didn't think about that that - might have belonged up in the question.
At this point I agree that the correct answer needs to be changed, and points retro-actively awarded... 🙂
June 28, 2010 at 12:32 am
Also, if the identity increment was -1, then both option 1 and 3 would be correct, as there is no clustered index to order it, and no ORDER BY statement specified, so either -1, -2, -3 or -3, -2, -1 could be the result.
June 28, 2010 at 12:35 am
Hi,
I think, before publish any question, it should be check by experts.
bcz, we all here to increase are knowledge and its spread wrong message to all. So i request to publisher, please check the question before publish.
Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
June 28, 2010 at 12:49 am
If you start with -1 and add 1, the correct answer according to me is -1, 0, 1.
I agree with a previous post that to get -1, -2 -3 you would have to start with -1 and substract 1.
Identity would then be identity (-1,-1).
Not often that I disagree with the correct answer, but this time I do because I think the answer is wrong.
Vera
June 28, 2010 at 12:57 am
I also expected the answer to be -1, 0, 1--glad to hear I'm not alone in this! And the explanation given seemed largely irrelevant--I never thought a primary key couldn't be negative.
June 28, 2010 at 1:02 am
bazzkar (6/26/2010)
Comments posted to this topic are about the item <A HREF="/questions/IDENTITY/69598/">What will be the output of the following?</A>
I am getting -1,0,1 only..
Kindly explain
June 28, 2010 at 1:02 am
Hi,
Identity has been set (-1, 1) that means first row will start with -1 and there will be 1 increment in subsequesnt rows so the answer should be
-1, 0, 1
June 28, 2010 at 1:13 am
is this a typo in the question?.
I think to get this answer the declartion of the identity should by (-1,-1)
June 28, 2010 at 1:13 am
Hey the answer to the Question is Wrong.
Viewing 15 posts - 16 through 30 (of 144 total)
You must be logged in to reply to this topic. Login to reply