June 26, 2010 at 11:14 am
Comments posted to this topic are about the item What will be the output of the following?
June 26, 2010 at 11:16 am
how come.. i am getting -1,0,1 only..
someone explain please
Kindest Regards,
Paarthasarathy
Microsoft Certified Technology Specialist
http://paarthasarathyk.blogspot.com
June 27, 2010 at 4:21 am
first - all available answers are wrong. "-1,-0,1" is the better looking although you will not get "-0"
second - with identity (-1,1) you can only get -1, 0, 1. If you want to get -1,-2,-3 you would need identity(-1,-1)
There is something wrong with either question or with the answers.
June 27, 2010 at 8:16 am
The table should be created with the identity (-1,-1). Then only we can get this result. Must be a typo error???.
June 27, 2010 at 9:51 pm
Since the question is wrong then everyone who selected "-1,0,1" should get a point!
:-):-D
June 27, 2010 at 10:10 pm
Yes, To get -1,-2,-3 identity should be -1 insteed of 1.
Regards,
Pankaj Bhandari
Microsoft Certified Technology Specialist
June 27, 2010 at 10:33 pm
Yeah!... i have executed the query in SSMS 2005... and I get the result as "-1,0,1"
we should get our points back... 😀
john-byrne (6/27/2010)
Since the question is wrong then everyone who selected "-1,0,1" should get a point!:-):-D
June 27, 2010 at 10:39 pm
With an identity of (-1,1), -1, -2 and -3 is just not the possible output.
The first record that goes in will have -1. Next would be -1 + 1 = 0. Finally, we would have 0 + 1 = 1.
It's probably just a typo, and I am sure the moderators will take a look and award the points.
The points not being awarded is a typical drawback with the automated evaluation systems - after all, all automation works on GIGO. If there was an error in framing the question, there's bound to be an error in the evaluation. Just another example of why automation should not be allowed work without supervision 🙂
Thanks & Regards,
Nakul Vachhrajani.
http://nakulvachhrajani.com
Follow me on
Twitter: @sqltwins
June 27, 2010 at 11:14 pm
The answer is -1,0,1. The provided answer is wrong. To get -1,-2,-3, we have to set the identity increment as -1.
Juts give the points... 10 times of the actual point..... 😉
June 27, 2010 at 11:30 pm
Even i am getting the answer as "-1, 0, 1".
I have executed the query in SQL 2008 Enterprise edition.
i am agreeing with others about the fact that
to get ans as -1, -2, -3, the seed value should be -1.
@Moderator :
Look in this.
June 27, 2010 at 11:43 pm
itseems like the answer or question posted is wrong!! 🙂
June 27, 2010 at 11:45 pm
Create Table MyTable( mainkey int not null identity (-1,1))
GO
insert into MyTable default values insert into MyTable default values insert into MyTable default values
Select * from MyTable
this will give result as this
-1
0
1
I think this type of question three weeks ago.this question is similar to the question on may 31 st 2010.
Malleswarareddy
I.T.Analyst
MCITP(70-451)
June 27, 2010 at 11:47 pm
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.
Malleswarareddy
I.T.Analyst
MCITP(70-451)
June 28, 2010 at 12:06 am
i think there is something wrong with this answer coz it should be
-1,0,1 but ans is -1,-2,-3.
June 28, 2010 at 12:11 am
I'm getting -1, 0, 1 as I would expect to be the right answer ( as almost all contributors)
Viewing 15 posts - 1 through 15 (of 144 total)
You must be logged in to reply to this topic. Login to reply