|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: Today @ 5:09 AM
Points: 31,526,
Visits: 13,864
|
|
|
|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: Today @ 5:09 AM
Points: 31,526,
Visits: 13,864
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, December 28, 2011 6:08 AM
Points: 2,
Visits: 19
|
|
in identity (-1,1) no first paramaeter shows number start from and second parameter shows number increment by mentioned. in that case "mainkey" will start from -1 and increased by 1. so Result will be
-1,0,1.
inf u will execute insert into MyTable default values
then mainkey will be -1
next time : insert into MyTable default values
mainkey =mainkey +1
so it will be 0
next time : insert into MyTable default values
mainkey =mainkey +1
so it will be 1
is it right ?
|
|
|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: Today @ 5:09 AM
Points: 31,526,
Visits: 13,864
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, April 22, 2011 10:44 AM
Points: 2,
Visits: 23
|
|
I object.
The question presented in the email had: mainkey int not null identity (-1,1)
but the code in the question and answer on the web site had: mainkey int not null identity (-1,-1)
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 9:45 AM
Points: 2,163,
Visits: 2,151
|
|
Sadowy,
I think it is very common for the questions/answers to be corrected/edited between when they are email and when you may get to the web site. Being on the west coast of the US corrections are normally made before I get up and attempt the question.
Given that I don't pay much attention to the question in the email, I always read and answer what is on the web site.
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Tuesday, December 07, 2010 8:13 AM
Points: 436,
Visits: 322
|
|
sadowy (6/30/2010) I object.
The question presented in the email had: mainkey int not null identity (-1,1)
but the code in the question and answer on the web site had: mainkey int not null identity (-1,-1)
EDIT: Removing grumpy comment that I added. Sorry, it has been a tough day. The reason the email and question are different is explained in the 13 previous pages. You probably do not have to look much past page 2.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Friday, June 07, 2013 11:59 AM
Points: 100,
Visits: 121
|
|
This may have been covered but can someone tell me why the answer says the order will be -1,-2,-3 since in the create table NO PK IS DEFINED? I understand that this is the order the data was inserted, but without a PK or more specificly a clustered index how can you be assured of the data sort order.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 9:45 AM
Points: 2,163,
Visits: 2,151
|
|
| badatthis: Yes, that issue has been brought up more than once. And I think it goes further than that, even with a PK/clustered index you aren't guaranteed a sort order unless you specify ORDER BY in your SELECT statement. (If I am wrong on this can somebody correct me?)
|
|
|
|
|
SSC-Insane
         
Group: General Forum Members
Last Login: Yesterday @ 7:02 PM
Points: 21,376,
Visits: 9,584
|
|
UMG Developer (6/30/2010) badatthis: Yes, that issue has been brought up more than once. And I think it goes further than that, even with a PK/clustered index you aren't guaranteed a sort order unless you specify ORDER BY in your SELECT statement. (If I am wrong on this can somebody correct me?)
no you're right.
|
|
|
|