用SQL产生一串5位数字的随机数:
declare @table table(c1 varchar(10))
declare @i int
set @i=0
while(@i<=9)
begin
Insert into @table select @i
set @i=@i+1
end
declare @s varchar(100)
set @s=''
select @s=@s+c1 from (select top 5 c1 from @table order by NewID()) T
select @s
/*
54879
74190
53142
65321
49670
*/
declare @i int
set @i=0
while(@i<=9)
begin
Insert into @table select @i
set @i=@i+1
end
declare @s varchar(100)
set @s=''
select @s=@s+c1 from (select top 5 c1 from @table order by NewID()) T
select @s
/*
54879
74190
53142
65321
49670
*/