You are here: Re: cursor application? « MsSQL Server « IT news, forums, messages
Re: cursor application?

Posted by Erland Sommarskog on 06/18/05 00:49

(chrisandkayenolan@gmail.com) writes:
> Cursors are a bad idea to use as they hold locks on tables for their
> duration. They are also not necessary as you can use set rowcount 1 to
> loop through records individually.

SET ROWCOUNT 1 is probably the worst form of iteration you can do. That
was what we did back in 4.x days, and it was no fun at all. When you
need to iterate, cursors are indeed the way to do.

Whether cursors hold locks or not, depends on what sort of cursor
you use. The default cursor type is a keyset cursor, a creature I
have never fully understood. Add INSENSITIVE before CURSOR, and you
don't have to worry. The result set for the cursor is fixed once
for all.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация