Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create random number
Message
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01545107
Message ID:
01545188
Views:
50
>>Unless you are running a lottery or something, I see no reason why you would want a random number. Generating of any random number implies the new number might already exist in the table.
>>
>>I also think it really unfortunate that you started by asking for a random number, and no one stops you to ask what do you intend to do with it. That resulted in a lot of noise that served no purpose.
>>
>>You seem to be requiring a number that is unique to each record. If not, please explain what you are doing.
>
>Yes, I do need a unique number to be set into a field of a table (not PK field). In VFP I have used the random number approach for this case and have not had any problems. Why could not the same work in SQL?

In VFP random number also doesn't guarantee to be unique. You may want to use NewID() (which is uniqueidentifier) if you need a unique value.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform