如何让结果WITH table AS
进入CURSOR
循环?我之前曾问过如何从我的表中获取递归结果
;with C as
(
definition ...
)
我创建了 CURSOR 循环,我想在其中为所有结果运行特定的存储过程table
declare @id int, @parent int
declare cur cursor local fast_forward
for
select id, parent from C
open cur
fetch next from cur into @id, @parent
while @@fetch_status = 0
begin
exec storedProcedure @id=@id, @parent=@parent
fetch next from cur into @id, @parent
end
close cur
deallocate cur
问题是 CURSOR 不知道table
WITH AS 结果。
Invalid object name 'C'.