Pages

Sunday, February 1, 2009

Cursors in SQL Server

SQL Server is very good at handling sets of data. For example, you can use a single UPDATE statement to update many rows of data. There are times when you want to loop through a series of rows a perform processing for each row. In this case you can use a cursor.

cursors are the SLOWEST way to access data inside SQL Server. The should only be used when you truly need to access one row at a time. The only reason I can think of for that is to call a stored procedure on each row.

cursors are over thirty times slower than normal SQL queries.

Reference : http://www.sqlteam.com/article/cursors-an-overview

No comments: