感觉存储过程有问题,你可以把你的表和你要完成的操作做一下说明
就是想从problem表中随机取n个ID插入到PaperDetail 表中吧。
[code]
WITH temp_A as (
select ID,random = newID() ,sectionID from problem
where sectionID = @sectionID
),
temp_B as(
select ID,rn = ROW_NUMBER() OVER(ORDER BY random),sectionID FROM temp_A
)INSERT INTO PaperDetail (TitleID)
SELECT ID FROM temp_B
WHERE temp_B.rn <= @n
[/code]
玉开
|
大侠五级
|园豆:8822
|
2008-07-17 13:12