Why is it considered bad practice to use cursors in SQL Server? -
i knew of performance reasons in sql 7 days, same issues still exist in sql server 2005? if have resultset in stored procedure want act upon individually, cursors still bad choice? if so, why?
because cursors take memory , create locks.
what doing attempting force set-based technology non-set based functionality. and, in fairness, should point out cursors do have use, frowned upon because many folks not used using set-based solutions use cursors instead of figuring out set-based solution.
but, when open cursor, loading rows memory , locking them, creating potential blocks. then, cycle through cursor, making changes other tables , still keeping of memory , locks of cursor open.
all of has potential cause performance issues other users.
so, general rule, cursors frowned upon. if that's first solution arrived @ in solving problem.
Comments
Post a Comment