开发者

Updating a column with random values between specific range?

开发者 https://www.devze.com 2023-01-27 14:00 出处:网络
I have a column where I need to update it\'s value b开发者_运维技巧y random numbers between 1 and 3150 (just being specific)

I have a column where I need to update it's value b开发者_运维技巧y random numbers between 1 and 3150 (just being specific)

Can I do this with a simple TSQL statement?


Use RAND(), re-seeding the function on each call.

UPDATE MyTable
SET MyColumn = 1 + FLOOR(3150 * RAND(CONVERT(varbinary, NEWID())))
WHERE ...
0

精彩评论

暂无评论...
验证码 换一张
取 消