Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create random number
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01545107
Message ID:
01545188
Vues:
51
>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform