伙计我想多次调用一个过程,输出多个行值作为过程的参数。我的查询是这样的:
select RoomID from tbWalkInRooms where WID =@ID
现在这个查询正在返回多个roomid,我每次都必须发送一个不同的roomid作为参数。
答案 0 :(得分:0)
我理解你的问题,你可以通过使用游标来实现:
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