﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Kalpesh Thaker / Article Discussions / Article Discussions by Author  / Cursor / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 00:06:34 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Cursor</title><link>http://www.sqlservercentral.com/Forums/Topic822885-207-1.aspx</link><description>[quote][b]tho.pfaff (11/21/2009)[/b][hr]ordinary queries grap the rows from the hard-disk, where the cpu needs more time to grap them. and erery time the sql-query is executed the a full table-scan must be performed to find the row.  [/quote]It is not always true that ordinary queries fetches the rows from hard disk.Regarding full table scan must  be performed to find a row, that would be true if the company has a policy of no indexes and would never use an index ....:-) :-).Your assumption is wrong Tommy, a full table scan happens when there are no indexes and can be avoided by having appropriate indexes..</description><pubDate>Sun, 22 Nov 2009 16:25:35 GMT</pubDate><dc:creator>Bru Medishetty</dc:creator></item><item><title>RE: Cursor</title><link>http://www.sqlservercentral.com/Forums/Topic822885-207-1.aspx</link><description>[quote]abstract:cursors (used in for loops):- sql-query to get the result-set is executed one time, to make a result set (in the initialsation-part of procedure)- one small result-set- fastest way for a cpu to grap the data, because they are in the ramordinary queries (used in for loops):- executed to get on row per query- in every execution the whole table has to be scaned to get one row, so there is no result-set to crawl over- no fast way for the cpu to grap the data, because data is on harddrive[/quote]I'm not sure who wrote that for you but it's mostly full of hooie... not all cursors are in ram just like not all non cursors are on disk.Basically, cursors will always be slower than "Set Based" queries because cursors (and While Loops) override the "natural" way that SQL Server operates.With only 1 exception in 10,000, you should simply avoid cursors.</description><pubDate>Sun, 22 Nov 2009 15:32:57 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Cursor</title><link>http://www.sqlservercentral.com/Forums/Topic822885-207-1.aspx</link><description>You should know that wether you are using cursors or a while loop it is still RBAR (a Modenism for Row By Agonizing Row) processing. In almost all cases, converting cursor-based solutions to set-based solutions will result in improved performance and scalability of your code.Instead of learning more about writing cursors, I use that energy to learn how to write set-based solutions.  If you must learn about cursors, use that to learn how to convert existing cursor-based solutions to set-based solutions.</description><pubDate>Sat, 21 Nov 2009 20:05:27 GMT</pubDate><dc:creator>Lynn Pettis</dc:creator></item><item><title>Cursor</title><link>http://www.sqlservercentral.com/Forums/Topic822885-207-1.aspx</link><description>hi @all,i want to know a bit more about cursors and the technical way they are realized. my understanding is, that cursors are pointers on a result-set within the ram. the result-set is small (comparing to the table the rows are from) and the sql which perform the result-set is executed only one time (i hope :o) ), right? So what we have is a small result-set within a location the cpu has the fastest way to grab rows from this result-set.why should this cursors (used in for loops) not be more efficient than ordinary sql-queries (in for loops)?ordinary queries grap the rows from the hard-disk, where the cpu needs more time to grap them. and erery time the sql-query is executed the a full table-scan must be performed to find the row.  abstract:cursors (used in for loops):- sql-query to get the result-set is executed one time, to make a result set (in the initialsation-part of procedure)- one small result-set- fastest way for a cpu to grap the data, because they are in the ramordinary queries (used in for loops):- executed to get on row per query- in every execution the whole table has to be scaned to get one row, so there is no result-set to crawl over- no fast way for the cpu to grap the data, because data is on harddrivewhat du you think about what my understanding of cursors is. am i right?please let me know.cheers tommy</description><pubDate>Sat, 21 Nov 2009 07:41:21 GMT</pubDate><dc:creator>tho.pfaff</dc:creator></item></channel></rss>