1.更新表中某个字段为随机值

update [Courses] set LearnsNum = cast(rand(checksum(newid()))*(999-100)+100 as int)

以下可参考,非原创

update [test].[dbo].[table]
 set [table.rand] = cast(rand(checksum(newid()))*(999999-100000)+100000 as float(6))

 select newid()   如:57C26BA5-8304-4877-B5D4-256C80428B94
 select rand()     如:0.029051900701824
 select checksum(500)    如:500
 select checksum(newid())    如:35757911
 select rand(checksum(newid()))    如:0.657911662715189
 select rand(checksum(newid()))*(999999-100000)+100000    如:881621.124049528
 select cast(rand(checksum(newid()))*(999999-100000)+100000 as float(6))   如:609545.7

 

相关文章:

  • 2021-11-30
  • 2021-11-29
  • 2022-01-05
  • 2021-09-12
  • 2021-11-30
  • 2021-11-04
猜你喜欢
  • 2022-12-23
  • 2022-01-20
  • 2021-11-30
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
相关资源
相似解决方案