[dba-SQLServer] Random autonumber ID

jwcolby jwcolby at colbyconsulting.com
Tue Jun 12 09:20:43 CDT 2012


The problem is that in order to revert you have to manually rebuild the autonumber PKs by moving the 
data into a new table with a new autonumber, plus the old "random" autonumber.  You then have to 
update all child tables with then new PK values.  This is darned ugly and error prone.

John W. Colby
Colby Consulting

Reality is what refuses to go away
when you do not believe in it

On 6/12/2012 5:27 AM, Gustav Brock wrote:
> Hi Mark
>
> Thanks, I didn't know that.
>
> By the way, I located this page:
> http://e-university.wisdomjobs.com/ms-access/chapter-1413-203/upsizing-access-to-sql-server.html
>
> which has a very good explanation of the pitfalls in the paragraph:
> "Replicated Databases and Random Autonumbers")
>
> This tells me that I once again should try to persuade the client to bite the bullet and revert to sequential IDs.
>
> /gustav
>
>
>>>> marklbreen at gmail.com 12-06-12 10:23>>>
> Hello Gustav,
>
> I think that SQL Server will automatically pick up at the largest number
> currently in the table and work away happily.  If not, you can easily set
> the starting number for the new range using DBCC CHECKIDENT
>
> In fact, if the last random number was 547845714  you could make the next
> Identity Insert start at 6000000000
>
> Mark
>
>
>
> On 11 June 2012 11:36, Gustav Brock<gustav at cactus.dk>  wrote:
>
>> Hi Arthur
>>
>> Nope. He (the client) just picked random autonumber for the IDs because he
>> somewhere had read that it had some advantages and - as we all know - the
>> number should be meaningless.
>>
>> So I think I will transfer the IDs as is and then see if I can change the
>> field to straight SQL Server autonumbering.
>> Does anyone know what happens when SQL Server for a new record "meets" an
>> ID that is already taken?
>>
>> /gustav
>>
>>
>>>>> fuller.artful at gmail.com 08-06-12 17:20>>>
>> Gustav,
>>
>> IMO this is not the best method, and not even the second or third best
>> method. If for reason you or the client doesn't like AutoNumber, that's
>> cool. I have dealt with such unruly clients in the past (c.f. my missive on
>> long-lasting hardware) Back to the subject: if for some asinine reason, the
>> client doesn't like AutoNumber, then present her with the alternative,
>> GUID, which according to MS's statisticians, is guaranteed to work for the
>> next 70+ years. By which time I shall be dead, and therefore unavailable
>>   for post-midnight fixes. Sorry, but Arthur has left the building.
>>
>> Which reminds me of a couple of websites I happened upon this week.
>>
>> "Why can't we just get a Bong?" Marijuana party of Canadia. And the other
>> one I forget. LOL.
>
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
>
>



More information about the dba-SQLServer mailing list