tsql - Advantages on using cursor variable in SQL Server (declare @cn cursor) -
in t-sql cursor can declared in 2 ways (that know of):
declare cursorname cursor ...
declare @cursorname cursor
i running tests , notice creation of cursor variable not add entry result of sp_cursor_list
.
is there advantage/disadvantage on using second approach point of view of performance, resource utilization, etc?
ps: i aware of potential cursor performance issues. not asking comparison on cursors vs set based. or cursor vs while
temp/table variable.
from read purpose of cursor variable able use output variable in stored proc, enabling send data in cursor controlling proc. have not tried don't know how work, reading books online. surprised if there measurable performance difference , not the improvement not using cursor in first place. if aren't planning use output variable, i'd suggest staying more common cursor definiton might make code easier maintain.
that said, there very, few cases cursor needed.
Comments
Post a Comment