--取得当前日期
select getdate()
--取得秒
select datepart(ms,getdate())*10000
--随机函数浮点型
select rand(datepart(ms,getdate())*10000)
--取出4个数字
select right(rand(datepart(ms,getdate())*10000),4)
--转化为字符串随机数
select Convert(varchar(10),right(rand(datepart(ms,getdate())*10000),4))
Sql Server随机数
最新推荐文章于 2025-01-03 18:00:00 发布
本文介绍如何在 SQL Server 中使用当前时间来生成随机数,并将其转化为四位数的字符串形式,适用于需要简单随机数的应用场景。

1327

被折叠的 条评论
为什么被折叠?



