-1

我有一个包含 10 个值的临时表,如下所示:

CREATE TABLE #RequireAuth (val1 int, val2 int /*, etc...*/ )

如何调用另一个存储这 10 个值并返回 6 个值的存储过程?

SELECT * FROM #RequireAuth  -- Not sure how to call a SP from here?

然后我需要获取这 6 个值并更新另一个表。

4

1 回答 1

0

我对您的临时表做了一些假设,因为您描述的内容和显示的内容不同,但这是 while 循环的基本概念。

CREATE TABLE #RequireAuth (val1 int, done bit default 0)

declare @varible int
        ,@count int


select @count =count(2) from #RequireAuth where done=0
while (@count>0) 
    BEGIn
        select top 1 @varible=val1 from #RequireAuth where done=0
        exec sp_YourProc @variable

        update R  set done=1 from #RequireAuth R where val1=@varible
        select @count =count(2) from #RequireAuth where done=0
END
于 2013-04-09T13:39:25.577 回答