Use the LOCAL option when declaring the cursor.
LOCAL
Specifies that the scope of the cursor
is local to the batch, stored
procedure, or trigger in which the
cursor was created. The cursor name is
only valid within this scope. The
cursor can be referenced by local
cursor variables in the batch, stored
procedure, or trigger, or a stored
procedure OUTPUT parameter. An OUTPUT
parameter is used to pass the local
cursor back to the calling batch,
stored procedure, or trigger, which
can assign the parameter to a cursor
variable to reference the cursor after
the stored procedure terminates. The
cursor is implicitly deallocated when
the batch, stored procedure, or
trigger terminates, unless the cursor
was passed back in an OUTPUT
parameter. If it is passed back in an
OUTPUT parameter, the cursor is
deallocated when the last variable
referencing it is deallocated or goes
out of scope.