答案 0 :(得分:0)
为什么你不能这样做:
declare @tbl table (id int, nm int)
;with src(id) as (
select 1 union all select id+1 from src where id+1 <= 100000
)
insert @tbl(id, nm)
select id, ROUND(((9) * RAND(cast(newid() as varbinary)) + 1), 0)
from src
option (maxrecursion 0)
select nm, count(9)qty
from @tbl
group by nm