<?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; Creating Comma Separate Values List from Table &#8211; UDF &#8211; SP</title>
	<atom:link href="http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/</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: Gyan</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-57073</link>
		<dc:creator>Gyan</dc:creator>
		<pubDate>Tue, 27 Oct 2009 13:25:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-57073</guid>
		<description>There is a better Option available for  the same job.


select cast(NumberCols as varchar)+&#039;,&#039; from NumberTable
for xml path (&#039;&#039;)

it saves so many operations and rest all query it self speaks.</description>
		<content:encoded><![CDATA[<p>There is a better Option available for  the same job.</p>
<p>select cast(NumberCols as varchar)+&#8217;,&#8217; from NumberTable<br />
for xml path (&#8221;)</p>
<p>it saves so many operations and rest all query it self speaks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tejas Shah</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-54326</link>
		<dc:creator>Tejas Shah</dc:creator>
		<pubDate>Fri, 31 Jul 2009 13:34:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-54326</guid>
		<description>Hi,

please refer: http://www.sqlyoga.com/2009/02/sql-server-get-comma-separated-list.html

Let me know if you have any other situations.

Thanks,

Tejas</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>please refer: <a href="http://www.sqlyoga.com/2009/02/sql-server-get-comma-separated-list.html" rel="nofollow">http://www.sqlyoga.com/2009/02/sql-server-get-comma-separated-list.html</a></p>
<p>Let me know if you have any other situations.</p>
<p>Thanks,</p>
<p>Tejas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shobhit Awasthi</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-54312</link>
		<dc:creator>Shobhit Awasthi</dc:creator>
		<pubDate>Fri, 31 Jul 2009 11:56:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-54312</guid>
		<description>Hi Pinal,

I want the record to be display

ID            Name

1              abc, cde, efg
2               111,222,333
3                56</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I want the record to be display</p>
<p>ID            Name</p>
<p>1              abc, cde, efg<br />
2               111,222,333<br />
3                56</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomek Cwajda</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-53581</link>
		<dc:creator>Tomek Cwajda</dc:creator>
		<pubDate>Thu, 09 Jul 2009 15:25:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-53581</guid>
		<description>Better I make some example:
-----------------------------------------------------------------
SELECT campaign_name
     , ( SELECT member_email +&#039;;&#039;
          FROM competition (NOLOCK)
         WHERE campaign_key = C.c_key 
         FOR XML PATH(&#039;&#039;)
       ) recipients
  FROM campaigns (NOLOCK) AS C
 WHERE DATE &gt; GETDATE()</description>
		<content:encoded><![CDATA[<p>Better I make some example:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
SELECT campaign_name<br />
     , ( SELECT member_email +&#8217;;&#8217;<br />
          FROM competition (NOLOCK)<br />
         WHERE campaign_key = C.c_key<br />
         FOR XML PATH(&#8221;)<br />
       ) recipients<br />
  FROM campaigns (NOLOCK) AS C<br />
 WHERE DATE &gt; GETDATE()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomek Cwajda</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-53579</link>
		<dc:creator>Tomek Cwajda</dc:creator>
		<pubDate>Thu, 09 Jul 2009 15:16:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-53579</guid>
		<description>I prefer such:

Select name+&#039;,&#039;
from something
for xml path(&#039;&#039;)


The POWER :-)  of this solution that you can use this in subquerys also.</description>
		<content:encoded><![CDATA[<p>I prefer such:</p>
<p>Select name+&#8217;,&#8217;<br />
from something<br />
for xml path(&#8221;)</p>
<p>The POWER :-)  of this solution that you can use this in subquerys also.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ila</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-52469</link>
		<dc:creator>Ila</dc:creator>
		<pubDate>Wed, 27 May 2009 09:48:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-52469</guid>
		<description>How to get only distinct rows as comma separated?</description>
		<content:encoded><![CDATA[<p>How to get only distinct rows as comma separated?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Creating comma separate list from table Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-45743</link>
		<dc:creator>SQL SERVER - Creating comma separate list from table Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Mon, 19 Jan 2009 19:15:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-45743</guid>
		<description>[...] February 20, 2007 by pinaldave    Update : (5/5/2007) I have updated the script to support SQL SERVER 2005.  Visit :SQL SERVER - Creating Comma Separate Values List from Table - UDF - SP [...]</description>
		<content:encoded><![CDATA[<p>[...] February 20, 2007 by pinaldave    Update : (5/5/2007) I have updated the script to support SQL SERVER 2005.  Visit :SQL SERVER &#8211; Creating Comma Separate Values List from Table &#8211; UDF &#8211; SP [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Valeda</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-44409</link>
		<dc:creator>Valeda</dc:creator>
		<pubDate>Wed, 26 Nov 2008 18:01:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-44409</guid>
		<description>Is it possible to get distinct values only?</description>
		<content:encoded><![CDATA[<p>Is it possible to get distinct values only?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ilija</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-44226</link>
		<dc:creator>Ilija</dc:creator>
		<pubDate>Fri, 14 Nov 2008 15:26:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-44226</guid>
		<description>Thanks you are the best...</description>
		<content:encoded><![CDATA[<p>Thanks you are the best&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shruti</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-39739</link>
		<dc:creator>Shruti</dc:creator>
		<pubDate>Thu, 03 Jul 2008 17:20:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-39739</guid>
		<description>Hi Pinal,

In my company we need to do opposite of above and that is parsing the comma seperated values into  rows of table.

I found following script which works very fast as I have parsed 20 million records in just under 5 mins.

Hope this will help others too.

--First Create a table with numeric values form 1 to 8000
CREATE TABLE Tally
        (ID INT)

DECLARE	@count INT 

SELECT	@count =1 

WHILE	@count &lt; 8001
BEGIN
        INSERT	INTO    Tally(ID)
        SELECT  @count 

		SELECT @count=@count+1
END 


SELECT  Comma_Seperated_List,
        NULLIF(SubString(&#039;,&#039; + product_list + &#039;,&#039; , ID , CharIndex(&#039;,&#039; , &#039;,&#039; + product_list + &#039;,&#039; , ID) - ID) , &#039;&#039;) AS &#039;Value&#039;
FROM    Tally T,
        My_table M
WHERE   ID                                              0 --remove this line to keep NULL rows


Your comments are appriciated.

Thanks,
SK</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>In my company we need to do opposite of above and that is parsing the comma seperated values into  rows of table.</p>
<p>I found following script which works very fast as I have parsed 20 million records in just under 5 mins.</p>
<p>Hope this will help others too.</p>
<p>&#8211;First Create a table with numeric values form 1 to 8000<br />
CREATE TABLE Tally<br />
        (ID INT)</p>
<p>DECLARE	@count INT </p>
<p>SELECT	@count =1 </p>
<p>WHILE	@count &lt; 8001<br />
BEGIN<br />
        INSERT	INTO    Tally(ID)<br />
        SELECT  @count </p>
<p>		SELECT @count=@count+1<br />
END </p>
<p>SELECT  Comma_Seperated_List,<br />
        NULLIF(SubString(&#8216;,&#8217; + product_list + &#8216;,&#8217; , ID , CharIndex(&#8216;,&#8217; , &#8216;,&#8217; + product_list + &#8216;,&#8217; , ID) &#8211; ID) , &#8221;) AS &#8216;Value&#8217;<br />
FROM    Tally T,<br />
        My_table M<br />
WHERE   ID                                              0 &#8211;remove this line to keep NULL rows</p>
<p>Your comments are appriciated.</p>
<p>Thanks,<br />
SK</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahendra Patil</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-39430</link>
		<dc:creator>Mahendra Patil</dc:creator>
		<pubDate>Mon, 23 Jun 2008 06:14:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-39430</guid>
		<description>Hi,

I used COALESCE in my project to reterive the comma separate values.

syntax :- 

COALESCE (storage, separetor, startvalue)

storage :-  variable which contain final output. In option 1 @listStr is storage.

separetor :- value which distigush between two item. for example here &#039;,&#039; (comma) you can put any value like &#039;/&#039;,&#039;A&#039;.

startvalue :- list start with this value.

for example 

I want Output : start , first,second,third,fourth,fifth

COALESCE(@listStr, &#039;,&#039; , &#039;start,&#039;).

thanks
Mahendra</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I used COALESCE in my project to reterive the comma separate values.</p>
<p>syntax :- </p>
<p>COALESCE (storage, separetor, startvalue)</p>
<p>storage :-  variable which contain final output. In option 1 @listStr is storage.</p>
<p>separetor :- value which distigush between two item. for example here &#8216;,&#8217; (comma) you can put any value like &#8216;/&#8217;,'A&#8217;.</p>
<p>startvalue :- list start with this value.</p>
<p>for example </p>
<p>I want Output : start , first,second,third,fourth,fifth</p>
<p>COALESCE(@listStr, &#8216;,&#8217; , &#8217;start,&#8217;).</p>
<p>thanks<br />
Mahendra</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Create a Comma Delimited List Using SELECT Clause From Table Column Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-39173</link>
		<dc:creator>SQL SERVER - Create a Comma Delimited List Using SELECT Clause From Table Column Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Thu, 12 Jun 2008 07:37:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-39173</guid>
		<description>[...] I have previously written similar article where I have demonstrated this method using three sample examples. You can read the article for further information. SQL SERVER - Creating Comma Separate Values List from Table - UDF - SP [...]</description>
		<content:encoded><![CDATA[<p>[...] I have previously written similar article where I have demonstrated this method using three sample examples. You can read the article for further information. SQL SERVER &#8211; Creating Comma Separate Values List from Table &#8211; UDF &#8211; SP [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mina</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-36430</link>
		<dc:creator>Mina</dc:creator>
		<pubDate>Fri, 02 May 2008 22:21:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-36430</guid>
		<description>Hi Pinal,

I have a column with dx codes separated by commas.  I need to break these out into separate columns within the same table.  How is this done or what is the best way to get this done?

Here is an example:
      DX                           
------------
V72.0, V32.0, 245.

OUTPUT NEEDED:
 
   DX                           DX1          DX2         DX3
--------                       -------         ------        -------
V72.0, V32.0, 245.       V72.0      V32.0       245


Thanks!
Mina</description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I have a column with dx codes separated by commas.  I need to break these out into separate columns within the same table.  How is this done or what is the best way to get this done?</p>
<p>Here is an example:<br />
      DX<br />
&#8212;&#8212;&#8212;&#8212;<br />
V72.0, V32.0, 245.</p>
<p>OUTPUT NEEDED:</p>
<p>   DX                           DX1          DX2         DX3<br />
&#8212;&#8212;&#8211;                       &#8212;&#8212;-         &#8212;&#8212;        &#8212;&#8212;-<br />
V72.0, V32.0, 245.       V72.0      V32.0       245</p>
<p>Thanks!<br />
Mina</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nikhil</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-19965</link>
		<dc:creator>Nikhil</dc:creator>
		<pubDate>Thu, 15 Nov 2007 08:18:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-19965</guid>
		<description>i tried using both ways 1st and 2nd
when i use these techniques on large set of data ,say one thousand records i get a timed out sql exception.this works fine on small amount of data (few rows).

how could i achieve  this on large data..................</description>
		<content:encoded><![CDATA[<p>i tried using both ways 1st and 2nd<br />
when i use these techniques on large set of data ,say one thousand records i get a timed out sql exception.this works fine on small amount of data (few rows).</p>
<p>how could i achieve  this on large data&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashant Pandey</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-12910</link>
		<dc:creator>Prashant Pandey</dc:creator>
		<pubDate>Mon, 17 Sep 2007 08:45:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-creating-comma-separate-values-list-from-table-udf-sp/#comment-12910</guid>
		<description>Hi Pinal,
U have used COALESCE( colname + &#039;,&#039;,&#039;&#039;)
What is the meaning of Second parameter here.????</description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
U have used COALESCE( colname + &#8216;,&#8217;,&#8221;)<br />
What is the meaning of Second parameter here.????</p>
]]></content:encoded>
	</item>
</channel>
</rss>
