Inner cursor performance issues Before I tried to avoid using cursor because of performance issues. But now I have to do some calculations to reach some goals. I have a stored procedure that has a code like this:

DECLARE  Outer_Cursor CURSOR FOR...

   OPEN Outer_Cursor
   FETCH NEXT FROM Outer_Cursor INTO ...

   WHILE @@FETCH_STATUS = 0
   BEGIN

      DECLARE  Inner_Cursor CURSOR  FOR...

      OPEN Outer_Cursor
      FETCH NEXT FROM Inner_Cursor INTO ...

      WHILE @@FETCH_STATUS = 0
      BEGIN

        ...

        FETCH NEXT FROM Inner_Cursor INTO ...
      END

      CLOSE Inner_Cursor
      DEALLOCATE Inner_Cursor    

      FETCH NEXT FROM Outer_Cursor INTO ...

  END

  CLOSE Outer_Cursor
  DEALLOCATE Outer_Cursor


My question is: is it possible to avoid (minimize) so expensive cursor recreation for inner cursor. How can I reuse inner cursor declaration, is it possible? 

Thank you.
I'd suggest that instead of using the inner cursor, if you want to avoid its creation and release for every step of the outer cursor, to use a temp table to fetch data and truncate it for each step.

That way you'll create it just once, and the truncation operation is not logged, so it will not cause any problems.

PS: in this situation I'm always in favor of temp tables with an identity column that will be looped for each record (or batches :-).
But I agree with the comments, better tell us the problem and maybe we'll find another solution.