[dba-SQLServer] Random autonumber ID

Stuart McLachlan stuart at lexacorp.com.pg
Tue Jun 12 17:43:11 CDT 2012


If the client wants the random numbers to look "different", seed the table with a large value 
such as 9,000,000,000,000.

-- 
Stuart

On 12 Jun 2012 at 17:06, Gustav Brock wrote:

> 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
> 
> _______________________________________________
> dba-SQLServer mailing list
> dba-SQLServer at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
> http://www.databaseadvisors.com
> 
> 

--
Stuart McLachlan

Ph:    +675 340 4392 
Mob: +675 7100 2028
Web: http://www.lexacorp.com.pg



More information about the dba-SQLServer mailing list