[dba-SQLServer] Random autonumber ID

Gustav Brock gustav at cactus.dk
Tue Jun 12 10:06:34 CDT 2012


Hi John

This, trivial and cumbersome. 

However, the client has accepted to move to sequential numbers. The reason for the random numbers were, that the column this way looked "different" when perusing the table. Not a very heavy argument, he admitted.

/gustav


>>> jwcolby at colbyconsulting.com 12-06-12 16:20 >>>
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



More information about the dba-SQLServer mailing list