I did it like this:
declare @sqlstr nvarchar(max)
set @sqlstr = ''
select @sqlstr = @sqlstr + ' exec deleteQuestion ' + cast(q.id as nvarchar(max))
from Questions q where stuff = @stuff
exec (@sqlstr)
I was told that this approach is much faster than the cursor
source
share