You are here: Re: How to Gnerate a Random ID Number « MsSQL Server « IT news, forums, messages
Re: How to Gnerate a Random ID Number

Posted by Gert-Jan Strik on 06/10/07 16:42

[snip]
> >>checksum(newid()) is better than the rand() function.
> >
> > Hi Erland,
> >
> > What exactly makes checksum(newid()) better than rand() ?
>
> Here is a practical reason:
>
> select rand(), checksum(newid())
> from (select n = 1 union all select 2 union all select 4) as x
>
> I believe that there also issues with the randomness of rand(), although
> I don't remember the exact details. Steve Kass knows the full story.

The rand() function is not random at all. It will give the next number
in from a repeatable sequence of numbers, based on the seed.

For more details, check out
http://groups.google.nl/group/microsoft.public.sqlserver.programming/browse_thread/thread/b7d0e057887380ca/0c1ff6c9523c19f0
(url may wrap)

Gert-Jan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация