<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; SQL SERVER &#8211; Simple Example of Recursive CTE &#8211; Part 2 &#8211; MAXRECURSION &#8211; Prevent CTE Infinite Loop</title>
	<atom:link href="http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Alain Holloway</title>
		<link>http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/#comment-57557</link>
		<dc:creator>Alain Holloway</dc:creator>
		<pubDate>Thu, 12 Nov 2009 16:39:20 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=751#comment-57557</guid>
		<description>Hi there!

I need help with recursive operation

I do have 2 tables

#1 Inspections
ID
PARENT_ID
POSITION

#2 Resources
RESOURCES_ID
CULTURE_LANGUAGE
CAPTION

DATA SAMPLE (OUTPUT)

SELECT a.id, a.parent_id, a.position, b.culture_language, b.caption 
FROM Inspections AS a 
INNER JOIN InspectionsResources AS b ON 
a.id = b.resource_id where culture_language=&#039;en&#039;

VEHICLES        ID = 1, PARENT_ID = 0, POSITION=1
FORKLIFTS       ID = 2, PARENT_ID = 0, POSITION=2
CARS               ID = 3, PARENT_ID = 1, POSITION=1
MOTORCYCLES ID = 4, PARENT_ID = 1, POSITION=2
DOORS            ID = 5, PARENT_ID = 3, POSITION=1
HANDLES          ID = 6, PARENT_ID = 3, POSITION=2
...

I need to load all data for CARS only!!

Thank you Pinal

Alain</description>
		<content:encoded><![CDATA[<p>Hi there!</p>
<p>I need help with recursive operation</p>
<p>I do have 2 tables</p>
<p>#1 Inspections<br />
ID<br />
PARENT_ID<br />
POSITION</p>
<p>#2 Resources<br />
RESOURCES_ID<br />
CULTURE_LANGUAGE<br />
CAPTION</p>
<p>DATA SAMPLE (OUTPUT)</p>
<p>SELECT a.id, a.parent_id, a.position, b.culture_language, b.caption<br />
FROM Inspections AS a<br />
INNER JOIN InspectionsResources AS b ON<br />
a.id = b.resource_id where culture_language=&#8217;en&#8217;</p>
<p>VEHICLES        ID = 1, PARENT_ID = 0, POSITION=1<br />
FORKLIFTS       ID = 2, PARENT_ID = 0, POSITION=2<br />
CARS               ID = 3, PARENT_ID = 1, POSITION=1<br />
MOTORCYCLES ID = 4, PARENT_ID = 1, POSITION=2<br />
DOORS            ID = 5, PARENT_ID = 3, POSITION=1<br />
HANDLES          ID = 6, PARENT_ID = 3, POSITION=2<br />
&#8230;</p>
<p>I need to load all data for CARS only!!</p>
<p>Thank you Pinal</p>
<p>Alain</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/#comment-57071</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Tue, 27 Oct 2009 13:21:26 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=751#comment-57071</guid>
		<description>@Raghuveer

A recursive CTE can potentially go on forever. So, SQL Server limits it to 100 cycles. MAXRECURSION allows you to change that limit between 1 and 32767 or 0 which means unlimited.</description>
		<content:encoded><![CDATA[<p>@Raghuveer</p>
<p>A recursive CTE can potentially go on forever. So, SQL Server limits it to 100 cycles. MAXRECURSION allows you to change that limit between 1 and 32767 or 0 which means unlimited.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raghuveer</title>
		<link>http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/#comment-57055</link>
		<dc:creator>Raghuveer</dc:creator>
		<pubDate>Tue, 27 Oct 2009 02:41:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=751#comment-57055</guid>
		<description>Hi Pinal,

I am student learning SQL server. I actaully didnot know what exactly maxrecursion function do?

can you please be precise.

Thanks&amp;Regards,

Raghuveer.</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I am student learning SQL server. I actaully didnot know what exactly maxrecursion function do?</p>
<p>can you please be precise.</p>
<p>Thanks&amp;Regards,</p>
<p>Raghuveer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ravi kiran</title>
		<link>http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/#comment-54846</link>
		<dc:creator>Ravi kiran</dc:creator>
		<pubDate>Fri, 14 Aug 2009 06:57:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=751#comment-54846</guid>
		<description>Hi pinal,

Thank you for the content, i was looking for the same.</description>
		<content:encoded><![CDATA[<p>Hi pinal,</p>
<p>Thank you for the content, i was looking for the same.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/#comment-50305</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Tue, 31 Mar 2009 19:58:38 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=751#comment-50305</guid>
		<description>@Prasant

Please provide an example query.</description>
		<content:encoded><![CDATA[<p>@Prasant</p>
<p>Please provide an example query.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prasant</title>
		<link>http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/#comment-50291</link>
		<dc:creator>Prasant</dc:creator>
		<pubDate>Tue, 31 Mar 2009 14:18:15 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=751#comment-50291</guid>
		<description>Hi Pinal,

Thanks for the post on CTE. Still I am not clear how can we restrict the recursion in CTE. Ex. The normal select statement (without MAXRECURSION) returns 10 records. If we give OPTION (MAXRECURSION 3), the query will throw error. If we give MAXRECURSION 4 or above it gives all the 10 records which is same as query without MAXRECURSION. Could you please clarify how can it restrict the recursion to say 3?</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Thanks for the post on CTE. Still I am not clear how can we restrict the recursion in CTE. Ex. The normal select statement (without MAXRECURSION) returns 10 records. If we give OPTION (MAXRECURSION 3), the query will throw error. If we give MAXRECURSION 4 or above it gives all the 10 records which is same as query without MAXRECURSION. Could you please clarify how can it restrict the recursion to say 3?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Haridas</title>
		<link>http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/#comment-42141</link>
		<dc:creator>Haridas</dc:creator>
		<pubDate>Thu, 28 Aug 2008 21:19:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=751#comment-42141</guid>
		<description>It’s easy to parse delimited string with WITH statement



DECLARE @txt as nvarchar(100)
SET  @txt = &#039;Banana;Chocolote;Milk;Bread&#039;

;WITH ParseText( Ltxt, Rtxt) AS (
      
       SELECT   --anchor member
          Ltxt  = LEFT (@txt,  CHARINDEX( &#039;;&#039;, @txt)  )
         ,Rtxt  = RIGHT(@txt, LEN(@txt) - CHARINDEX( &#039;;&#039;,@txt) ) 

       UNION ALL --Recursive member
       SELECT 
     
          Ltxt  = LEFT(tn.Rtxt, CHARINDEX( &#039;;&#039;,tn.Rtxt) )
         ,Rtxt  = RIGHT(tn.Rtxt, LEN(tn.Rtxt) - CHARINDEX( &#039;;&#039;,tn.Rtxt) )
    FROM ParseText tn where Ltxt  &#039;&#039; -- Recursive loop
    )
    SELECT
       Ltxt = CASE WHEN Ltxt = &#039;&#039; THEN RTxt ELSE Ltxt END
    FROM ParseText</description>
		<content:encoded><![CDATA[<p>It’s easy to parse delimited string with WITH statement</p>
<p>DECLARE @txt as nvarchar(100)<br />
SET  @txt = &#8216;Banana;Chocolote;Milk;Bread&#8217;</p>
<p>;WITH ParseText( Ltxt, Rtxt) AS (</p>
<p>       SELECT   &#8211;anchor member<br />
          Ltxt  = LEFT (@txt,  CHARINDEX( &#8216;;&#8217;, @txt)  )<br />
         ,Rtxt  = RIGHT(@txt, LEN(@txt) &#8211; CHARINDEX( &#8216;;&#8217;,@txt) ) </p>
<p>       UNION ALL &#8211;Recursive member<br />
       SELECT </p>
<p>          Ltxt  = LEFT(tn.Rtxt, CHARINDEX( &#8216;;&#8217;,tn.Rtxt) )<br />
         ,Rtxt  = RIGHT(tn.Rtxt, LEN(tn.Rtxt) &#8211; CHARINDEX( &#8216;;&#8217;,tn.Rtxt) )<br />
    FROM ParseText tn where Ltxt  &#8221; &#8212; Recursive loop<br />
    )<br />
    SELECT<br />
       Ltxt = CASE WHEN Ltxt = &#8221; THEN RTxt ELSE Ltxt END<br />
    FROM ParseText</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kristina</title>
		<link>http://blog.sqlauthority.com/2008/07/29/sql-server-sql-server-simple-example-of-recursive-cte-part-2-maxrecursion-prevent-cte-infinite-loop/#comment-41131</link>
		<dc:creator>Kristina</dc:creator>
		<pubDate>Thu, 31 Jul 2008 17:56:40 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=751#comment-41131</guid>
		<description>Thanks for this and your previous examples regarding recursion on SQL server. I was fond of oracle&#039;s connect by, and sad to see that it didn&#039;t exist in SQL Server. This did the trick, though! Thanks again!</description>
		<content:encoded><![CDATA[<p>Thanks for this and your previous examples regarding recursion on SQL server. I was fond of oracle&#8217;s connect by, and sad to see that it didn&#8217;t exist in SQL Server. This did the trick, though! Thanks again!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
