SQL Server为每一行设置一个随机数

本文不再更新,可能存在内容过时的情况,实时更新请访问原地址:SQL Server为每一行设置一个随机数

本文不再更新,可能存在内容过时的情况,实时更新请访问原地址:SQL Server为每一行设置一个随机数;;

本文不再更新,可能存在内容过时的情况,实时更新请访问原地址:SQL Server为每一行设置一个随机数;;

使用:

  1. 查询:
select *, ABS(CHECKSUM(NewId())) % 20 + 65 as new_score from training_score;
  1. 修改:
update training_score set score = ABS(CHECKSUM(NewId())) % 20 + 65 where score is null;

参考:

  1. How do I generate random number for each row in a TSQL Select?
posted @ 2020-10-29 09:39  Cobcmw  阅读(576)  评论(0编辑  收藏  举报