SQLServer更新一组随机数
--创建用于生成随机数的视图
create view view_rand
as
select cast(rand()*20 as int) as rd
go
--创建生成随机数的标量函数
create function getRand()
returns int
as
begin
return (select rd from view_rand)
end
go
--测试
--select dbo.getRand()
--更新随机0-19的随机值
update [QPAccountsDB].[dbo].[AccountsInfo] set FaceID=dbo.getRand() where IsAndroid=1
select * from [QPAccountsDB].[dbo].[AccountsInfo] where IsAndroid=1
drop view view_rand
drop function getRand