<?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; Comma Separated Values (CSV) from Table Column</title>
	<atom:link href="http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sun, 12 Feb 2012 09:22:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Santosh Varma</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-245646</link>
		<dc:creator><![CDATA[Santosh Varma]]></dc:creator>
		<pubDate>Mon, 30 Jan 2012 09:37:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-245646</guid>
		<description><![CDATA[Pinal Dave,

               I have the following query:


SELECT  
c.CompanyID,
c.CompanyName,
ISNULL(c.LogoFileName,&#039;&#039;) AS LogoFileName,
ISNULL(c.City,&#039;&#039;) AS City, 
ISNULL(s.strState,&#039;&#039;) as [State], 
ISNULL(m.Mode,&#039;&#039;) as Mode             
     FROM tblCompany c         
     INNER JOIN tblCompanyPartners tcmp on c.CompanyID = tcmp.PartnerCompanyID         
     LEFT OUTER JOIN tblStates s ON C.StateID = S.intStateID              
     LEFT OUTER JOIN tblCompanyModes cm on c.CompanyID = cm.CompanyID              
     LEFT OUTER JOIN tblMode m ON cm.ModeID = m.ModeID WHERE c.PartnerTypeID IN (1,2) 
     AND C.CompanyID 31 
     and c.CompanyID not in (select PartnerCompanyID from tblCompanyCarrierPartners where [Status] IN (&#039;Blocked&#039;,&#039;Requested&#039;,&#039;Accepted&#039;) and tblCompanyCarrierPartners.CompanyID = 31) order by companyid desc


The following result is returned:

18  christ carrier company file1  San Jose  New Hampshire	LTL
18  christ carrier company file1  San Jose  New Hampshire     Oversize
14  Milton  	          file2  Dallas       California	Intermodal


Now, I need to get the following result:

18  christ carrier company file1  San Jose  New Hampshire     LTL, Oversize
14  Milton  	          file2  Dallas       California	Intermodal

I am really stuck up with this task.  Any help is appreciated.

Thanks,
Varma]]></description>
		<content:encoded><![CDATA[<p>Pinal Dave,</p>
<p>               I have the following query:</p>
<p>SELECT<br />
c.CompanyID,<br />
c.CompanyName,<br />
ISNULL(c.LogoFileName,&#8221;) AS LogoFileName,<br />
ISNULL(c.City,&#8221;) AS City,<br />
ISNULL(s.strState,&#8221;) as [State],<br />
ISNULL(m.Mode,&#8221;) as Mode<br />
     FROM tblCompany c<br />
     INNER JOIN tblCompanyPartners tcmp on c.CompanyID = tcmp.PartnerCompanyID<br />
     LEFT OUTER JOIN tblStates s ON C.StateID = S.intStateID<br />
     LEFT OUTER JOIN tblCompanyModes cm on c.CompanyID = cm.CompanyID<br />
     LEFT OUTER JOIN tblMode m ON cm.ModeID = m.ModeID WHERE c.PartnerTypeID IN (1,2)<br />
     AND C.CompanyID 31<br />
     and c.CompanyID not in (select PartnerCompanyID from tblCompanyCarrierPartners where [Status] IN (&#8216;Blocked&#8217;,'Requested&#8217;,'Accepted&#8217;) and tblCompanyCarrierPartners.CompanyID = 31) order by companyid desc</p>
<p>The following result is returned:</p>
<p>18  christ carrier company file1  San Jose  New Hampshire	LTL<br />
18  christ carrier company file1  San Jose  New Hampshire     Oversize<br />
14  Milton  	          file2  Dallas       California	Intermodal</p>
<p>Now, I need to get the following result:</p>
<p>18  christ carrier company file1  San Jose  New Hampshire     LTL, Oversize<br />
14  Milton  	          file2  Dallas       California	Intermodal</p>
<p>I am really stuck up with this task.  Any help is appreciated.</p>
<p>Thanks,<br />
Varma</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Khan</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-227915</link>
		<dc:creator><![CDATA[Khan]]></dc:creator>
		<pubDate>Thu, 29 Dec 2011 10:38:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-227915</guid>
		<description><![CDATA[I HAVE THE BELOW SCRIPT 

select DISTINCT expiry from Rec_Dtl where grn_number =27964 and m_code =&#039;M605&#039;

THE RERSUTLS  ARE

exiry
-------
382268;  07/02/05
976131,  31/05/2011


I WANT THE SEPRATE TWO VALUES LIKE BELOW.

DISTINCT EXPIRY 1 , EXPRIY 2
-------------------------------------
                  382268          07/02/05
                  976131         31/05/2011
 
I WANT RESULTS EXACTLY LIKE ABOVE. PLEASE HELP ME.]]></description>
		<content:encoded><![CDATA[<p>I HAVE THE BELOW SCRIPT </p>
<p>select DISTINCT expiry from Rec_Dtl where grn_number =27964 and m_code =&#8217;M605&#8242;</p>
<p>THE RERSUTLS  ARE</p>
<p>exiry<br />
&#8212;&#8212;-<br />
382268;  07/02/05<br />
976131,  31/05/2011</p>
<p>I WANT THE SEPRATE TWO VALUES LIKE BELOW.</p>
<p>DISTINCT EXPIRY 1 , EXPRIY 2<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
                  382268          07/02/05<br />
                  976131         31/05/2011</p>
<p>I WANT RESULTS EXACTLY LIKE ABOVE. PLEASE HELP ME.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: davidn</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-201979</link>
		<dc:creator><![CDATA[davidn]]></dc:creator>
		<pubDate>Tue, 22 Nov 2011 07:05:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-201979</guid>
		<description><![CDATA[For anybody that had the issue of any ampersands being entitized as &quot;&amp; amp;&quot; in your query result - see below for the syntax. That baked my head for a few hours. It uses the xquery .value to convert back to Nvarchar to avoid that issue. Example below Field1 is the key and FieldText is the one I want to summarize as a comma separated value list.

SELECT DISTINCT tm.Field1

STUFF(( SELECT DISTINCT &#039;, &#039; + [FieldText] as [text()]
			FROM Table1 ts
			WHERE tm.Field1 = ts.Field1
			FOR XML path(&#039;&#039;), TYPE
			).value(N&#039;.&#039;, N&#039;nvarchar(max)&#039;), 1, 1,&#039;&#039;) as Field1CSV

FROM Table1 tm]]></description>
		<content:encoded><![CDATA[<p>For anybody that had the issue of any ampersands being entitized as &#8220;&amp; amp;&#8221; in your query result &#8211; see below for the syntax. That baked my head for a few hours. It uses the xquery .value to convert back to Nvarchar to avoid that issue. Example below Field1 is the key and FieldText is the one I want to summarize as a comma separated value list.</p>
<p>SELECT DISTINCT tm.Field1</p>
<p>STUFF(( SELECT DISTINCT &#8216;, &#8216; + [FieldText] as [text()]<br />
			FROM Table1 ts<br />
			WHERE tm.Field1 = ts.Field1<br />
			FOR XML path(&#8221;), TYPE<br />
			).value(N&#8217;.', N&#8217;nvarchar(max)&#8217;), 1, 1,&#8221;) as Field1CSV</p>
<p>FROM Table1 tm</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-187109</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 14:36:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-187109</guid>
		<description><![CDATA[Refer this method
http://beyondrelational.com/blogs/madhivanan/archive/2008/09/11/splitting-delimited-data-to-columns-set-based-approach.aspx]]></description>
		<content:encoded><![CDATA[<p>Refer this method<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2008/09/11/splitting-delimited-data-to-columns-set-based-approach.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2008/09/11/splitting-delimited-data-to-columns-set-based-approach.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-187108</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 14:35:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-187108</guid>
		<description><![CDATA[Refer this. It will solve your problem
http://beyondrelational.com/blogs/madhivanan/archive/2010/03/17/bulk-insert-to-table-with-specific-columns.aspx]]></description>
		<content:encoded><![CDATA[<p>Refer this. It will solve your problem<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2010/03/17/bulk-insert-to-table-with-specific-columns.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2010/03/17/bulk-insert-to-table-with-specific-columns.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-187064</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 13:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-187064</guid>
		<description><![CDATA[2 is used to omit the leading comma, 200000 is just a number that would be maximum length of the resulted string. You can use any number in place of 200000]]></description>
		<content:encoded><![CDATA[<p>2 is used to omit the leading comma, 200000 is just a number that would be maximum length of the resulted string. You can use any number in place of 200000</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-187062</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 13:21:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-187062</guid>
		<description><![CDATA[You can use Order by clause. However you need to use Top 100 Percent in the SELECT clause]]></description>
		<content:encoded><![CDATA[<p>You can use Order by clause. However you need to use Top 100 Percent in the SELECT clause</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-187054</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 02 Nov 2011 13:11:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-187054</guid>
		<description><![CDATA[What is the datatype of @value? It should be nvarchar(max). Also you can simply use



SELECT  SUBSTRING(
(SELECT &#039;,&#039; + l.name
FROM sys.syslanguages l
FOR XML PATH(&#039;&#039;)),2,200000) as csv]]></description>
		<content:encoded><![CDATA[<p>What is the datatype of @value? It should be nvarchar(max). Also you can simply use</p>
<p>SELECT  SUBSTRING(<br />
(SELECT &#8216;,&#8217; + l.name<br />
FROM sys.syslanguages l<br />
FOR XML PATH(&#8221;)),2,200000) as csv</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jules Bartow</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-184251</link>
		<dc:creator><![CDATA[Jules Bartow]]></dc:creator>
		<pubDate>Thu, 27 Oct 2011 18:12:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-184251</guid>
		<description><![CDATA[Pinal Dave,

Thank you for all that you do. 

I was wondering why you don&#039;t like Greeks, Bulgarians, Russians, Chinese,  Koreans and Thais?   

Their language gets question marked when I run your T-SQL on the sys.syslanguages table in SQL 2008 R2.


SELECT langid, name,alias FROM sys.syslanguages

SELECT @value = SUBSTRING(
(SELECT &#039;,&#039; + l.name
FROM sys.syslanguages l
FOR XML PATH(&#039;&#039;)),2,200000)

us_english,Deutsch,Français,???,Dansk,Español,Italiano,Nederlands,Norsk,Português,Suomi,Svenska,ceština,magyar,polski,româna,hrvatski,slovencina,slovenski,e???????,?????????,???????,Türkçe,British,eesti,latviešu,lietuviu,Português (Brasil),????,???,????,Arabic,???]]></description>
		<content:encoded><![CDATA[<p>Pinal Dave,</p>
<p>Thank you for all that you do. </p>
<p>I was wondering why you don&#8217;t like Greeks, Bulgarians, Russians, Chinese,  Koreans and Thais?   </p>
<p>Their language gets question marked when I run your T-SQL on the sys.syslanguages table in SQL 2008 R2.</p>
<p>SELECT langid, name,alias FROM sys.syslanguages</p>
<p>SELECT @value = SUBSTRING(<br />
(SELECT &#8216;,&#8217; + l.name<br />
FROM sys.syslanguages l<br />
FOR XML PATH(&#8221;)),2,200000)</p>
<p>us_english,Deutsch,Français,???,Dansk,Español,Italiano,Nederlands,Norsk,Português,Suomi,Svenska,ceština,magyar,polski,româna,hrvatski,slovencina,slovenski,e???????,?????????,???????,Türkçe,British,eesti,latviešu,lietuviu,Português (Brasil),????,???,????,Arabic,???</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max Manus</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-175182</link>
		<dc:creator><![CDATA[Max Manus]]></dc:creator>
		<pubDate>Tue, 04 Oct 2011 22:37:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-175182</guid>
		<description><![CDATA[Your information helped me a lot. thanks]]></description>
		<content:encoded><![CDATA[<p>Your information helped me a lot. thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-168004</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 14 Sep 2011 11:36:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-168004</guid>
		<description><![CDATA[Use Bulk insert statement]]></description>
		<content:encoded><![CDATA[<p>Use Bulk insert statement</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sudheshna</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-167999</link>
		<dc:creator><![CDATA[Sudheshna]]></dc:creator>
		<pubDate>Wed, 14 Sep 2011 11:20:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-167999</guid>
		<description><![CDATA[Hi,

How can I insert comma separated strings in to diffrent rows of a table, with a single insert statement?]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>How can I insert comma separated strings in to diffrent rows of a table, with a single insert statement?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-163584</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 30 Aug 2011 11:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-163584</guid>
		<description><![CDATA[This is the formation issue that should be done in the front end application]]></description>
		<content:encoded><![CDATA[<p>This is the formation issue that should be done in the front end application</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Muthu</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-163310</link>
		<dc:creator><![CDATA[Muthu]]></dc:creator>
		<pubDate>Mon, 29 Aug 2011 19:57:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-163310</guid>
		<description><![CDATA[Hi Folks,

I have a integer field. For an instance i have a value like this 1500000. I want to return the value like this 1,500,000. 

Any idea about this.

Thank you 
Muthu]]></description>
		<content:encoded><![CDATA[<p>Hi Folks,</p>
<p>I have a integer field. For an instance i have a value like this 1500000. I want to return the value like this 1,500,000. </p>
<p>Any idea about this.</p>
<p>Thank you<br />
Muthu</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yash thakkar</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-158688</link>
		<dc:creator><![CDATA[yash thakkar]]></dc:creator>
		<pubDate>Thu, 18 Aug 2011 05:07:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-158688</guid>
		<description><![CDATA[Thanks Pinal....the above xample which you have mentioned regarding that coma separated values(CSV)....thast amazing and helped a lot


Regards,
Yash]]></description>
		<content:encoded><![CDATA[<p>Thanks Pinal&#8230;.the above xample which you have mentioned regarding that coma separated values(CSV)&#8230;.thast amazing and helped a lot</p>
<p>Regards,<br />
Yash</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harish</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-144976</link>
		<dc:creator><![CDATA[Harish]]></dc:creator>
		<pubDate>Fri, 01 Jul 2011 00:51:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-144976</guid>
		<description><![CDATA[Pinal, can you please help me with this. I know I can go with a stored proc, but for some reasons, I shouldn’t use it.
allowed_file_extensions in table UPLOAD has comma separated values from table FILE_EXTENSIONS
if allowed_file_extensions has atleast one entry with comma separated, and that has is_enabled = 0, then it should return 0.
It will return 1 only if for all values (comma separted) has is_enabled = 1
FILE_EXTENSIONS
id	description	is_enabled
1	.xls		1
2	.doc		1
3	.pdf		1
4	.rtf		1
5	.gif		1
6	.jpeg		1
7	.jpg		1
8	.docx		1
9	.mpeg		0
10	.mp3		0

UPLOAD
upload_id	upload_name		allowed_file_extensions
1		Template1		.xls, .doc, .pdf, .mp3, .mpeg, .pptx, .txt
2		Template2		.xls, .doc, .pdf, .rtf, .mp3, .jpeg, .jpg, .pptx, .txt
3		Template3		.xls, .doc, .pdf, .rtf, .gif, .pptx, .txt

Required Output in a view
upload_id	is_enabled		allowed_file_extensions
1		0			.xls, .doc, .pdf, .mp3, .mpeg, .pptx, .txt
2		0			.xls, .doc, .pdf, .mp3, .jpeg, .jpg, .pptx, .txt
3		1			.xls, .doc, .pdf, .rtf, .gif, .pptx, .txt]]></description>
		<content:encoded><![CDATA[<p>Pinal, can you please help me with this. I know I can go with a stored proc, but for some reasons, I shouldn’t use it.<br />
allowed_file_extensions in table UPLOAD has comma separated values from table FILE_EXTENSIONS<br />
if allowed_file_extensions has atleast one entry with comma separated, and that has is_enabled = 0, then it should return 0.<br />
It will return 1 only if for all values (comma separted) has is_enabled = 1<br />
FILE_EXTENSIONS<br />
id	description	is_enabled<br />
1	.xls		1<br />
2	.doc		1<br />
3	.pdf		1<br />
4	.rtf		1<br />
5	.gif		1<br />
6	.jpeg		1<br />
7	.jpg		1<br />
8	.docx		1<br />
9	.mpeg		0<br />
10	.mp3		0</p>
<p>UPLOAD<br />
upload_id	upload_name		allowed_file_extensions<br />
1		Template1		.xls, .doc, .pdf, .mp3, .mpeg, .pptx, .txt<br />
2		Template2		.xls, .doc, .pdf, .rtf, .mp3, .jpeg, .jpg, .pptx, .txt<br />
3		Template3		.xls, .doc, .pdf, .rtf, .gif, .pptx, .txt</p>
<p>Required Output in a view<br />
upload_id	is_enabled		allowed_file_extensions<br />
1		0			.xls, .doc, .pdf, .mp3, .mpeg, .pptx, .txt<br />
2		0			.xls, .doc, .pdf, .mp3, .jpeg, .jpg, .pptx, .txt<br />
3		1			.xls, .doc, .pdf, .rtf, .gif, .pptx, .txt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: karthi</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-141890</link>
		<dc:creator><![CDATA[karthi]]></dc:creator>
		<pubDate>Sat, 18 Jun 2011 14:16:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-141890</guid>
		<description><![CDATA[Hi all,
I need to convert the values in a column which is separated by comma to different column  as follows,

Address						Id	Phone
--------------------------------------------------------------------
345 Ram Nagar,Mumbai,MH,425124,India		12345	9945721543
123 rajaji Nagar,Bangalore,KA,524212,India	67890	8235645678

convert to this

Address 	Street		 City       State  Zip	   Country   Id	    Phone
--------------------------------------------------------------------------------------
same as above	345 Ram Nagar	 Mumbai	    MH	   425124  India     12345  9945721543
same as above	123 rajaji Nagar Bangalore  KA	   524212  India     67890  8235645678]]></description>
		<content:encoded><![CDATA[<p>Hi all,<br />
I need to convert the values in a column which is separated by comma to different column  as follows,</p>
<p>Address						Id	Phone<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
345 Ram Nagar,Mumbai,MH,425124,India		12345	9945721543<br />
123 rajaji Nagar,Bangalore,KA,524212,India	67890	8235645678</p>
<p>convert to this</p>
<p>Address 	Street		 City       State  Zip	   Country   Id	    Phone<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
same as above	345 Ram Nagar	 Mumbai	    MH	   425124  India     12345  9945721543<br />
same as above	123 rajaji Nagar Bangalore  KA	   524212  India     67890  8235645678</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sonal</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-135840</link>
		<dc:creator><![CDATA[Sonal]]></dc:creator>
		<pubDate>Sat, 21 May 2011 04:53:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-135840</guid>
		<description><![CDATA[Hello,

I have to insert  csv or excel file into sql server table.my table contains 6 fields but i want to insert only single column values from excel/csv.

please give me reply.

Thank you.]]></description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>I have to insert  csv or excel file into sql server table.my table contains 6 fields but i want to insert only single column values from excel/csv.</p>
<p>please give me reply.</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-131766</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Thu, 28 Apr 2011 14:13:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-131766</guid>
		<description><![CDATA[select substring(col,patindex(&#039;%[a-b]%&#039;,col),col),len(col)) from table]]></description>
		<content:encoded><![CDATA[<p>select substring(col,patindex(&#8216;%[a-b]%&#8217;,col),col),len(col)) from table</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raj</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-131441</link>
		<dc:creator><![CDATA[Raj]]></dc:creator>
		<pubDate>Wed, 27 Apr 2011 09:56:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-131441</guid>
		<description><![CDATA[I have one table. One column &#039;Name&#039; got values like - &quot;1234,abcdef&quot;
So, I want to display Name values like &quot;abcdef&quot;. Need to avoid &quot;1234,&quot; in value.

What function we have to use for this. Please let me know the sql query.

Thanks]]></description>
		<content:encoded><![CDATA[<p>I have one table. One column &#8216;Name&#8217; got values like &#8211; &#8220;1234,abcdef&#8221;<br />
So, I want to display Name values like &#8220;abcdef&#8221;. Need to avoid &#8220;1234,&#8221; in value.</p>
<p>What function we have to use for this. Please let me know the sql query.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patel Rikin</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-129143</link>
		<dc:creator><![CDATA[Patel Rikin]]></dc:creator>
		<pubDate>Sat, 16 Apr 2011 05:37:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-129143</guid>
		<description><![CDATA[Why r u use SubString function and give the 20000 fixed length.
If i have a very big query then what happend?????????????????]]></description>
		<content:encoded><![CDATA[<p>Why r u use SubString function and give the 20000 fixed length.<br />
If i have a very big query then what happend?????????????????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eswar</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-123314</link>
		<dc:creator><![CDATA[Eswar]]></dc:creator>
		<pubDate>Tue, 15 Mar 2011 10:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-123314</guid>
		<description><![CDATA[SELECT DISTINCT  ISSUE_ID,  
	STUFF ((SELECT     &#039;, &#039; + PO_NUMBER + &#039; ( &#039;+  CONVERT(VARCHAR(30), QUANTITY_ISSUED) + &#039;  &#039; + UOM +&#039; ) &#039;  FROM  @temp WHERE CHLD.ISSUE_ID = MAIN.ISSUE_ID  FOR XML PATH(&#039;&#039;)), 1, 1, &#039;&#039;)AS PO_NUMBER
	FROM @temp AS MAIN]]></description>
		<content:encoded><![CDATA[<p>SELECT DISTINCT  ISSUE_ID,<br />
	STUFF ((SELECT     &#8216;, &#8216; + PO_NUMBER + &#8216; ( &#8216;+  CONVERT(VARCHAR(30), QUANTITY_ISSUED) + &#8216;  &#8216; + UOM +&#8217; ) &#8216;  FROM  @temp WHERE CHLD.ISSUE_ID = MAIN.ISSUE_ID  FOR XML PATH(&#8221;)), 1, 1, &#8221;)AS PO_NUMBER<br />
	FROM @temp AS MAIN</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kajal</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-122538</link>
		<dc:creator><![CDATA[kajal]]></dc:creator>
		<pubDate>Wed, 09 Mar 2011 13:04:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-122538</guid>
		<description><![CDATA[SELECT
  STUFF(
    (
    SELECT
      &#039;,&#039; + cast(Citation_Id as nvarchar(500))
    FROM tollplus.violated_trips
    FOR XML PATH(&#039;&#039;)
    ), 1, 1, &#039;&#039;
  ) As CitationId



here we are getting the column values with CSV, bt i want to get with html  tag then..
plz send me the solution]]></description>
		<content:encoded><![CDATA[<p>SELECT<br />
  STUFF(<br />
    (<br />
    SELECT<br />
      &#8216;,&#8217; + cast(Citation_Id as nvarchar(500))<br />
    FROM tollplus.violated_trips<br />
    FOR XML PATH(&#8221;)<br />
    ), 1, 1, &#8221;<br />
  ) As CitationId</p>
<p>here we are getting the column values with CSV, bt i want to get with html  tag then..<br />
plz send me the solution</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shyam</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-118995</link>
		<dc:creator><![CDATA[Shyam]]></dc:creator>
		<pubDate>Thu, 17 Feb 2011 16:53:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-118995</guid>
		<description><![CDATA[Pinal very good article.

Thanks
Shyam]]></description>
		<content:encoded><![CDATA[<p>Pinal very good article.</p>
<p>Thanks<br />
Shyam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Naveen</title>
		<link>http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/#comment-116011</link>
		<dc:creator><![CDATA[Naveen]]></dc:creator>
		<pubDate>Fri, 04 Feb 2011 10:40:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=7133#comment-116011</guid>
		<description><![CDATA[Thanks for this wornderful article. Our entire team learnt new things. 

-Naveen]]></description>
		<content:encoded><![CDATA[<p>Thanks for this wornderful article. Our entire team learnt new things. </p>
<p>-Naveen</p>
]]></content:encoded>
	</item>
</channel>
</rss>

