Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Random distribution
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01275589
Message ID:
01326527
Vues:
19
>>>>The little problem is that I have my work on a separate computer, so it would be a bit of a hassle to post the code here.
>>>
>>>
>>>Take a look in RAND() function in BOL.
>>
>>I did, but could not figure out how to apply it to get a random record.
>
>
>SELECT TOP xxx  *, NEWID() as Test
>       FROM YoutTable
>ORDER BY NEWID()
>
>
>where xxx is any number from 1 to ...
>
>I thought you want to SET values not to SELECT records

This worked
update Schools set SchoolPhone = '718-805-9999' FROM schools INNER JOIN (SELECT TOP 20 School, NEWID() as Test
       FROM Schools ORDER BY NEWID()) RandSchools ON Schools.School = RandSchools.School
Nice technique.
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