sql生成某范围内的随机数
分类:sql server 人气:1019 评论:0 时间:2011-04-06 22:24
rand() 返回从 0 到 1 之间的随机 float 值。
select ceiling(rand()*1000)
=======================
declare @n int,@m int
set @n=1
set @m=10
declare @ids varchar(max)
set @ids = ''
while @n<=@m
begin
set @ids = @ids + ',' + REPLACE(str(ceiling(rand()*1000)),' ','')
set @n=@n+1
end
if (@ids!='')
set @ids = '0'+@ids
print @ids