﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Dave Ballantyne  / Optimizing a cursor based routine – Part 1 / 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>Wed, 22 May 2013 01:22:10 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>Hi Jerome,Glad you enjoyed the series,I cant confirm right now but im pretty sure the links i gave point to the correct AW database.It may not of installed correct on your machine due to filestream issues,try this link [url]http://msftdbprodsamples.codeplex.com/releases/view/59211[/url]I *think* that should be the same</description><pubDate>Fri, 01 Jul 2011 07:04:26 GMT</pubDate><dc:creator>Dave Ballantyne</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>Dave, excellent job with the post! Very informative and good example to demo the technology.Big Question: Where can I find the AdventureWorks2008R2 database?I was running it against the AdventureWorks database but some of the columns/tables are missing....I have downloaded almost everything off codeplex, and I have found these databases:1) adventureworks2) adventureworksDW3) adventureworksDW20084) adventureworksDW2008R25) adventureworksLT6) adventureworksLT2008R2But no database named "AdventureWorks2008R2"?</description><pubDate>Thu, 30 Jun 2011 15:47:53 GMT</pubDate><dc:creator>jerome.landis</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>Just a couple of typo points really.The function SumCustomerTotals returns a table with CustomerTotalDue and shippedtotal but your example function call in the 6th code box selects different column names. (I think the function name was wrong originally but is fixed now).I also wondered if the last code box should be split to have just the GetMinOrderDates function declaration in one box and the GetSalesReport_Optimize1 procedure in a seperate box.Avidly reading these two articles as I'm still trying to 'unlearn' the procedural mindset! Thanks.</description><pubDate>Thu, 30 Jun 2011 04:04:48 GMT</pubDate><dc:creator>twillcomp</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>[quote][b]wbrianwhite (6/28/2011)[/b]I just looked at it now that it's up.  It uses a temp table and a lot of outer apply functions and multiple CTEs.  It is a simple enough report to write as just a select.  Anything else seems like the wrong tool.  Keep it simple and describe what you want in your sql, not how to get it.[/quote]Hi Brian,And that is really where it ends up,  i took the view , that you are completley welcome to disagree with, that it was better and more informative to the general reader to break the routine down in small easy(ish) lumps.I could of simply stated that A) the original proc is bad and B) the new proc is good and left out a lot of the in between, though i think that would of been of a lesser value.</description><pubDate>Wed, 29 Jun 2011 02:44:31 GMT</pubDate><dc:creator>Dave Ballantyne</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>[quote][b]WayneS (6/28/2011)[/b][hr][quote][b]wbrianwhite (6/28/2011)[/b][hr]I'm not sure why you're keeping this in a cursor at all.  The report looks simple enough to just write the entire report as a big select statement.  Which will be an order of magnitude faster than a cursor.[/quote]Surely you did notice that this article is "Part 1"? I would suspect that "Part 2" takes care of that! ;-)[/quote]I just looked at it now that it's up.  It uses a temp table and a lot of outer apply functions and multiple CTEs.  It is a simple enough report to write as just a select.  Anything else seems like the wrong tool.  Keep it simple and describe what you want in your sql, not how to get it.</description><pubDate>Tue, 28 Jun 2011 18:14:33 GMT</pubDate><dc:creator>wbrianwhite</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>Excellent Dave. I really like the progression you take for resolving this.</description><pubDate>Tue, 28 Jun 2011 16:21:16 GMT</pubDate><dc:creator>WayneS</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>[quote][b]wbrianwhite (6/28/2011)[/b][hr]I'm not sure why you're keeping this in a cursor at all.  The report looks simple enough to just write the entire report as a big select statement.  Which will be an order of magnitude faster than a cursor.[/quote]Surely you did notice that this article is "Part 1"? I would suspect that "Part 2" takes care of that! ;-)</description><pubDate>Tue, 28 Jun 2011 16:20:33 GMT</pubDate><dc:creator>WayneS</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>Great article, Dave! Very well done!</description><pubDate>Tue, 28 Jun 2011 15:06:51 GMT</pubDate><dc:creator>LutzM</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>For simplicity of example? </description><pubDate>Tue, 28 Jun 2011 14:44:34 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>I'm not sure why you're keeping this in a cursor at all.  The report looks simple enough to just write the entire report as a big select statement.  Which will be an order of magnitude faster than a cursor.</description><pubDate>Tue, 28 Jun 2011 14:32:19 GMT</pubDate><dc:creator>wbrianwhite</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>Nice article, well written, very informational, good explanations. I look forward to future articles from you.</description><pubDate>Tue, 28 Jun 2011 11:59:13 GMT</pubDate><dc:creator>KWymore</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>Thanks Jason,It was a long hard slog to get it to this point.Glad you enjoyed itFYI : Part 2 is now active here [url]http://www.sqlservercentral.com/articles/T-SQL/73889/[/url]</description><pubDate>Tue, 28 Jun 2011 07:47:18 GMT</pubDate><dc:creator>Dave Ballantyne</dc:creator></item><item><title>RE: Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>Nice Job Dave.</description><pubDate>Mon, 27 Jun 2011 16:27:34 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>Optimizing a cursor based routine – Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic1131888-2856-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/articles/T-SQL/73887/"&gt;Optimizing a cursor based routine – Part 1&lt;/A&gt;[/B]</description><pubDate>Mon, 27 Jun 2011 00:02:38 GMT</pubDate><dc:creator>Dave Ballantyne</dc:creator></item></channel></rss>