Replacing Cursors | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Replacing Cursors

I have a task where I need to call about 7 stored procedures for each company in our database. The stored procs need to be called in a different order for each company based on a priority. I know how to handle this using embedded cursors, but I am very concerned this will take too long. Can anyone suggest how I can better perform this task?
You can use a loop (it might or might not perform better, because it’s basically doing the same thing as a fast-forward cursor): declare a table variable with an identity column insert into the table variable a list of the items to process set i = 1
set end = max( identity column from the table variable ) while i <= end
begin — do things using the ith item in the table variable set i = i + 1
Thanks I will give this a try