UPDATE `表名` SET `字段名`=ceiling(rand()*500000+500000) WHERE (条件);  

原文链接:http://blog.csdn.net/bobay/article/details/24797525



MMP 上面的只能更新一条


UPDATE `表名` SET `字段名`=cast(rand(checksum(newid()))*(24)+1 as int) WHERE (条件);  

上面的就是每条都更新的了


下面的只供学习,具体以后能不能用得上,以后再说:::


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

欢迎留言