tsql - Advantages on using cursor variable in SQL Server (declare @cn cursor) -


in t-sql cursor can declared in 2 ways (that know of):

  1. declare cursorname cursor ...
  2. 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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -