0

伙计们,我想多次调用一个过程,并输出多个行值作为过程的参数。我的查询是这样的:

select RoomID from tbWalkInRooms where WID =@ID

现在这个查询返回了多个 roomid,我每次都必须将一个不同的 roomid 作为参数发送给一个过程。

4

1 回答 1

0

据我了解您的问题,您可以通过 ysing 光标来实现:

declare @room_id int

declare room_id_cursor cursor for select RoomID from tbWalkInRooms where WID =@ID
open room_id_cursor
fetch next from room_id_cursor into @room_id
while @@fetch_status = 0
begin
  exec your_procedure @room_id
  fetch next from room_id_cursor into @room_id
end
close room_id_cursor
deallocate room_id_cursor
于 2013-04-19T12:18:59.053 回答