<?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; Simple Example of Recursive CTE</title>
	<atom:link href="http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/</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: Neel</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-56542</link>
		<dc:creator>Neel</dc:creator>
		<pubDate>Thu, 08 Oct 2009 20:13:13 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-56542</guid>
		<description>Thanks for sharing it.. I was studing CTEs wnd WITH vigorously. Since CTEs are used for recursive executions, I tried to use CTE to solve my below problem, is there any way you think it could be done with CTE?

table1:
ack	SeqId	freq_type
1	1	9
1	2	9
1	3	9
1	4	9
1	5	9
1	6	5
1	7	5
1	8	5
1	9	9
1	10	9
1	11	9

Result should be:

ack	SeqId	freq_type
1	1	9
1	6	5
1	9	9


The logic shoolud be keep looping freq_type column untill it&#039;s last value changes..If changed then add it to resultset... 

I thought and concluded that result can be achived if SQL in recursive section could support &#039;top&#039; clauses..

any thoughts?

thanks for all your articles.</description>
		<content:encoded><![CDATA[<p>Thanks for sharing it.. I was studing CTEs wnd WITH vigorously. Since CTEs are used for recursive executions, I tried to use CTE to solve my below problem, is there any way you think it could be done with CTE?</p>
<p>table1:<br />
ack	SeqId	freq_type<br />
1	1	9<br />
1	2	9<br />
1	3	9<br />
1	4	9<br />
1	5	9<br />
1	6	5<br />
1	7	5<br />
1	8	5<br />
1	9	9<br />
1	10	9<br />
1	11	9</p>
<p>Result should be:</p>
<p>ack	SeqId	freq_type<br />
1	1	9<br />
1	6	5<br />
1	9	9</p>
<p>The logic shoolud be keep looping freq_type column untill it&#8217;s last value changes..If changed then add it to resultset&#8230; </p>
<p>I thought and concluded that result can be achived if SQL in recursive section could support &#8216;top&#8217; clauses..</p>
<p>any thoughts?</p>
<p>thanks for all your articles.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marco</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-53176</link>
		<dc:creator>marco</dc:creator>
		<pubDate>Mon, 22 Jun 2009 21:24:20 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-53176</guid>
		<description>This exact question was in the MCTS 70-433 exam. Did you take it from there or did you microsoft used it from here??</description>
		<content:encoded><![CDATA[<p>This exact question was in the MCTS 70-433 exam. Did you take it from there or did you microsoft used it from here??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shriram</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-51207</link>
		<dc:creator>Shriram</dc:creator>
		<pubDate>Wed, 22 Apr 2009 11:25:15 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-51207</guid>
		<description>Hi ,

Can i use a CTE for this scenario:
I have a transaction table with an id column and a name column and also i have master table with the same id column.
I need to concatenate all names for each id present in both tables and display it as a comma separated string along with the id

I dont want to use cursors or loops

Please help.

Thanks in advance</description>
		<content:encoded><![CDATA[<p>Hi ,</p>
<p>Can i use a CTE for this scenario:<br />
I have a transaction table with an id column and a name column and also i have master table with the same id column.<br />
I need to concatenate all names for each id present in both tables and display it as a comma separated string along with the id</p>
<p>I dont want to use cursors or loops</p>
<p>Please help.</p>
<p>Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 怀恋春晨</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-51089</link>
		<dc:creator>怀恋春晨</dc:creator>
		<pubDate>Sat, 18 Apr 2009 06:50:44 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-51089</guid>
		<description>Pinal,

You would get the same result by running a simple SELECT...I still don&#039;t see the usage of recursive CTE in this case, or is it just a different way of getting same result? Could you provive some scenarios for R. CTE? Thanks!

SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate
FROM HumanResources.Employee
order by ManagerID</description>
		<content:encoded><![CDATA[<p>Pinal,</p>
<p>You would get the same result by running a simple SELECT&#8230;I still don&#8217;t see the usage of recursive CTE in this case, or is it just a different way of getting same result? Could you provive some scenarios for R. CTE? Thanks!</p>
<p>SELECT EmployeeID, ContactID, LoginID, ManagerID, Title, BirthDate<br />
FROM HumanResources.Employee<br />
order by ManagerID</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Real Drouin</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-49221</link>
		<dc:creator>Real Drouin</dc:creator>
		<pubDate>Mon, 16 Mar 2009 21:14:03 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-49221</guid>
		<description>It&#039;s working well but I have an issue. Let say that I for each manager I want to sort the employee by hiring date.

How can I do that ?</description>
		<content:encoded><![CDATA[<p>It&#8217;s working well but I have an issue. Let say that I for each manager I want to sort the employee by hiring date.</p>
<p>How can I do that ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - 2008 - Interview Questions and Answers - Part 6 Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-47476</link>
		<dc:creator>SQL SERVER - 2008 - Interview Questions and Answers - Part 6 Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Thu, 26 Feb 2009 12:05:15 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-47476</guid>
		<description>[...] CTE is an abbreviation Common Table Expression. A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. (Read More Here) [...]</description>
		<content:encoded><![CDATA[<p>[...] CTE is an abbreviation Common Table Expression. A Common Table Expression (CTE) is an expression that can be thought of as a temporary result set which is defined within the execution of a single SQL statement. A CTE is similar to a derived table in that it is not stored as an object and lasts only for the duration of the query. (Read More Here) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Palanivel</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-45229</link>
		<dc:creator>Palanivel</dc:creator>
		<pubDate>Wed, 31 Dec 2008 11:18:59 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-45229</guid>
		<description>Hi Pinal 

Is there any Possiblility to use CTE in entire Stored procedure like Temp table. if i use CTE table more than one time its showing &#039;invalid object name&#039;.


Thanks &amp; Regards
R. Palanivel</description>
		<content:encoded><![CDATA[<p>Hi Pinal </p>
<p>Is there any Possiblility to use CTE in entire Stored procedure like Temp table. if i use CTE table more than one time its showing &#8216;invalid object name&#8217;.</p>
<p>Thanks &amp; Regards<br />
R. Palanivel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahul Jain</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-45130</link>
		<dc:creator>Rahul Jain</dc:creator>
		<pubDate>Sat, 27 Dec 2008 14:48:39 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-45130</guid>
		<description>Hi,

I&#039;ve following problem, which I&#039;ve not been able to do successfully. Your help will be appreciated.

Table has following 2 columns

DocNum    DocEntry
1               234
2               324
2               746
3               876
3              764
4              100
4              387

Expected result is as follow

1                 234
2                 324, 746
3                 876, 764
4                 100, 387

Thanks
Rahul Jain</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I&#8217;ve following problem, which I&#8217;ve not been able to do successfully. Your help will be appreciated.</p>
<p>Table has following 2 columns</p>
<p>DocNum    DocEntry<br />
1               234<br />
2               324<br />
2               746<br />
3               876<br />
3              764<br />
4              100<br />
4              387</p>
<p>Expected result is as follow</p>
<p>1                 234<br />
2                 324, 746<br />
3                 876, 764<br />
4                 100, 387</p>
<p>Thanks<br />
Rahul Jain</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Preeti Muley</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-41342</link>
		<dc:creator>Preeti Muley</dc:creator>
		<pubDate>Tue, 05 Aug 2008 10:37:28 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-41342</guid>
		<description>Hi Pinal I do have a query in Oracle as follows 
SELECT
  (BALLOT_DATA.BALLOT_FROM + (BALLOT_NO -1)) AS BALLOT_NO,
  ELECTION.ELEC_PK,
  ELECTION_AREAS.NAME AS ELECTION_AREA,
  BD_PK,
  BALLOT_DATA.PO_PK,
  BALLOT_DATA.SYSTEMID,
  PREFIX,
  SUFFIX,
  BALLOT_FROM,
  BALLOT_TO,
  BALLOT_NO AS RELATIVE_BALLOT_NO
  FROM
  (
  SELECT
      ROWNUM BALLOT_NO
  FROM
    DUAL CONNECT BY ROWNUM &lt;= 10000) BALLOT_PAPERS,
    BALLOT_DATA, ELECTION, ELECTION_AREAS
  WHERE
    BALLOT_PAPERS.BALLOT_NO &lt;= BALLOT_DATA.ORDINARY_COUNT AND
    ELECTION.ELEC_PK = 10 AND
    ELECTION_AREAS.ELA_PK = 35
can you suggest me the solution?</description>
		<content:encoded><![CDATA[<p>Hi Pinal I do have a query in Oracle as follows<br />
SELECT<br />
  (BALLOT_DATA.BALLOT_FROM + (BALLOT_NO -1)) AS BALLOT_NO,<br />
  ELECTION.ELEC_PK,<br />
  ELECTION_AREAS.NAME AS ELECTION_AREA,<br />
  BD_PK,<br />
  BALLOT_DATA.PO_PK,<br />
  BALLOT_DATA.SYSTEMID,<br />
  PREFIX,<br />
  SUFFIX,<br />
  BALLOT_FROM,<br />
  BALLOT_TO,<br />
  BALLOT_NO AS RELATIVE_BALLOT_NO<br />
  FROM<br />
  (<br />
  SELECT<br />
      ROWNUM BALLOT_NO<br />
  FROM<br />
    DUAL CONNECT BY ROWNUM &lt;= 10000) BALLOT_PAPERS,<br />
    BALLOT_DATA, ELECTION, ELECTION_AREAS<br />
  WHERE<br />
    BALLOT_PAPERS.BALLOT_NO &lt;= BALLOT_DATA.ORDINARY_COUNT AND<br />
    ELECTION.ELEC_PK = 10 AND<br />
    ELECTION_AREAS.ELA_PK = 35<br />
can you suggest me the solution?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ayman yassin</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-41275</link>
		<dc:creator>ayman yassin</dc:creator>
		<pubDate>Mon, 04 Aug 2008 08:51:22 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-41275</guid>
		<description>thanks alot</description>
		<content:encoded><![CDATA[<p>thanks alot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jessy . K</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-41044</link>
		<dc:creator>Jessy . K</dc:creator>
		<pubDate>Wed, 30 Jul 2008 09:34:32 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-41044</guid>
		<description>Hi,
  Can u tell me the books to study about SQL SERVER for the beginner.</description>
		<content:encoded><![CDATA[<p>Hi,<br />
  Can u tell me the books to study about SQL SERVER for the beginner.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manumik</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-40978</link>
		<dc:creator>manumik</dc:creator>
		<pubDate>Tue, 29 Jul 2008 13:07:45 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-40978</guid>
		<description>Very interesting!</description>
		<content:encoded><![CDATA[<p>Very interesting!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niyaz</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-40974</link>
		<dc:creator>Niyaz</dc:creator>
		<pubDate>Tue, 29 Jul 2008 12:29:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-40974</guid>
		<description>very useful !

Thanks alot.</description>
		<content:encoded><![CDATA[<p>very useful !</p>
<p>Thanks alot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamran Shahid</title>
		<link>http://blog.sqlauthority.com/2008/07/28/sql-server-simple-example-of-recursive-cte/#comment-40881</link>
		<dc:creator>Kamran Shahid</dc:creator>
		<pubDate>Mon, 28 Jul 2008 06:12:07 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=748#comment-40881</guid>
		<description>Thanks Pinal.
Now I am able to understand it</description>
		<content:encoded><![CDATA[<p>Thanks Pinal.<br />
Now I am able to understand it</p>
]]></content:encoded>
	</item>
</channel>
</rss>
