Wednesday, March 7, 2012

How to delete or drop a cursor?

Could anybody please tell me how to detete or drop a cursor?

Thanks,

-RL

A cursor is automatically dropped when the connection terminates.

But, if you want to do it manaully, use "CLOSE cursorname" and then "DEALLOCATE cursorname". See Books OnLine under @.@.FETCH_STATUS has a full example.|||Thanks a lot Tom.|||

Also, be sure to declare the cursor as LOCAL, or use a cursor variable

declare @.cursor cursor
set @.cursor = cursor for...

These are much safer to use, and will deallocate themselves if you don't.

|||Thanks a lot Louis.

No comments:

Post a Comment