|
Posted by Hugo Kornelis on 10/02/08 11:44
On 3 Apr 2006 13:48:16 -0700, Ramaarneh wrote:
>Hi,
> I want to create a random unique auto generated number. dont want
>to use GUIDs. Any other way to create it in isert statement itself,
>apart from storing a number in a table and increment while inserting.
>Help me!
Hi Ramaarneh,
Strange requirements. Why not a GUID? Why not store it in a table?
But if you must, then you might consider using the RAND() function. Put
it in a loop and iterate until an unused value is found. (Make sure that
the range of numbers that the RAND() can generate is at least 1000 times
bigger than the expected number of rows, to make sure that the loop will
iterate just once in most cases - otherwise, it'll be a performance
hog).
--
Hugo Kornelis, SQL Server MVP
Navigation:
[Reply to this message]
|