samedi 9 janvier 2021

how to update 4 000 000 random numbers of records in sql server

i have in totale 10 000 000 lignes and i want to update random records with some values , i want to update random ( 4 000 000 ) with the Datakey = 1 , next random 4 000 000 with a Datakey = 2 and the last 2 000 000 with a Datakey = 3 . I tried to learn some function like Rand() and i want to use it in my request but i couldn't . i could only use the top 4 000 000 to change them but i want a random records not the first 4 000 000 here is my request :

    update top (4 000 000) [FACT_INTERNATIONAL]  set [DateKey] = 2  

but i want the random 4 000 000 not the top . i am using sql server 2017 . thank you for help in advance




Aucun commentaire:

Enregistrer un commentaire