The answer becomes more clearer if you look at the current value of the identity using
dbcc checkident('region')
run this after the creation of the table and you get
Checking identity information:
current identity value 'NULL', current column value 'NULL'.
meaning, it's currently at 'null' but I'll be incrementing in 1's so the next value will be 1
Then after forcing the insert with `set identity_insert on`, you will get
Checking identity information:
current identity value '1', current column value '1'.
because you've stated that this identity will start at 1. You've added rows, but haven't gone past 1 with the value for the identity field, so the current value is the same as if you've added one row 'normally', hence the next value is 2.
The reason for that is that the next value is always the value of the greatest value, or seed start value + 1 (or whatever increment you've defined), in other words (max of -99, -9, 1) = 1 + 1 = 2.
In the same way you could add 2 rows 'normally' and then reseed at 100 : (max of 1,2,100) = 100 +1 = 101 would be the next identity value.
↧