日期:2014-05-18 浏览次数:20648 次
select top 1000 id = RIGHT(100000000 + CONVERT(bigint, ABS(CHECKSUM(NEWID()))), 8) from dbo.spt_values a,dbo.spt_values b,dbo.spt_values c
------解决方案--------------------
将你得到的数据保存到临时#Table,若是有重复的就重新获得。
declare @i int
set @i=0
while @i<5
begin
select @I= Count(distinct NUM) from #a
insert into #a
SELECT CAST (RAND() *10 AS INT ) AS NUM
end