like this,declare @id int,@tsql varchar(6000) declare ap scroll cursor for select id from [表名] where [条件]open ap fetch first from ap into @id while(@@fetch_status<>-1) begin select @tsql='exec [存储过程名] @id='+rtrim(@id) exec(@tsql) fetch next from ap into @id endclose ap deallocate ap
declare ap scroll cursor for
select id from [表名] where [条件]open ap
fetch first from ap into @id
while(@@fetch_status<>-1)
begin
select @tsql='exec [存储过程名] @id='+rtrim(@id)
exec(@tsql)
fetch next from ap into @id
endclose ap
deallocate ap