Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12345»»»

What will be the output of the following? Expand / Collapse
Author
Message
Posted Sunday, June 27, 2010 11:43 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, May 8, 2014 12:29 AM
Points: 50, Visits: 25
itseems like the answer or question posted is wrong!!
Post #943652
Posted Sunday, June 27, 2010 11:45 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:43 AM
Points: 1,938, Visits: 1,162
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)
Post #943654
Posted Sunday, June 27, 2010 11:47 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Monday, July 21, 2014 3:43 AM
Points: 1,938, Visits: 1,162
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)
Post #943656
Posted Monday, June 28, 2010 12:06 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, June 25, 2014 2:10 AM
Points: 242, Visits: 94
i think there is something wrong with this answer coz it should be
-1,0,1 but ans is -1,-2,-3.
Post #943660
Posted Monday, June 28, 2010 12:11 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, May 1, 2014 4:18 AM
Points: 1,218, Visits: 46
I'm getting -1, 0, 1 as I would expect to be the right answer ( as almost all contributors)
Post #943664
Posted Monday, June 28, 2010 12:14 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, June 27, 2014 8:02 AM
Points: 3,241, Visits: 4,996
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...


----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Sometimes, winning is not an issue but trying.

You can check my BLOG here

Post #943665
Posted Monday, June 28, 2010 12:14 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Tuesday, July 6, 2010 12:31 AM
Points: 663, Visits: 36
I think the question is wrong.
incase identity(-1,-1) then the answer ll be correct other wise will get -1,0,1 only.
Post #943666
Posted Monday, June 28, 2010 12:18 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, March 8, 2012 1:46 AM
Points: 148, Visits: 31
ditto

John
Post #943667
Posted Monday, June 28, 2010 12:22 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 10:17 AM
Points: 1,886, Visits: 786
Must be typing mistake from the author of this question... but how can we have "-0" in the result.

Regards,
Rals
.
Post #943668
Posted Monday, June 28, 2010 12:23 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, June 17, 2014 2:51 AM
Points: 413, Visits: 238
I think this is a typo.I want my point.
Post #943670
« Prev Topic | Next Topic »

Add to briefcase ««12345»»»

Permissions Expand / Collapse