<?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; Create a Comma Delimited List Using SELECT Clause From Table Column</title>
	<atom:link href="http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Mon, 13 Feb 2012 15:11:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Sara</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-248960</link>
		<dc:creator><![CDATA[Sara]]></dc:creator>
		<pubDate>Mon, 06 Feb 2012 13:03:49 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-248960</guid>
		<description><![CDATA[Since the column datatype is a VARCHAR type and you have combination of values, please use like operator.
Select * from table where RoleID like &#039;%3%&#039;]]></description>
		<content:encoded><![CDATA[<p>Since the column datatype is a VARCHAR type and you have combination of values, please use like operator.<br />
Select * from table where RoleID like &#8216;%3%&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adday Michel</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-247415</link>
		<dc:creator><![CDATA[Adday Michel]]></dc:creator>
		<pubDate>Fri, 03 Feb 2012 10:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-247415</guid>
		<description><![CDATA[please try below query

use AdventureWorks
Go
Delcare @listStr VARCHAR(MAX)
select @listStr =COALESCE(@listStr+’,’ ,”) + ProductData.Name
from(select distinct Name from Production.Product) as ProductData 
SELECT @listStr
Go]]></description>
		<content:encoded><![CDATA[<p>please try below query</p>
<p>use AdventureWorks<br />
Go<br />
Delcare @listStr VARCHAR(MAX)<br />
select @listStr =COALESCE(@listStr+’,’ ,”) + ProductData.Name<br />
from(select distinct Name from Production.Product) as ProductData<br />
SELECT @listStr<br />
Go</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kipetcoff</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-247393</link>
		<dc:creator><![CDATA[kipetcoff]]></dc:creator>
		<pubDate>Fri, 03 Feb 2012 09:40:57 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-247393</guid>
		<description><![CDATA[perfect!]]></description>
		<content:encoded><![CDATA[<p>perfect!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ROMY</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-231691</link>
		<dc:creator><![CDATA[ROMY]]></dc:creator>
		<pubDate>Thu, 05 Jan 2012 07:17:41 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-231691</guid>
		<description><![CDATA[HOW TO USE SELECT STATEMENTS INSTEAD OF ARGUMENTS IN SPLIT COMMA FUNCTION incase of ms sql 2008 server?it returns value for the below query

select LISTMEMBER from SysAdmin.fnSplitComma (&#039;2,3,5&#039;)

like LISTMEMBER
       2
       3
       5
but how to get the value when we specifies a column in table which has data in the format 2,3,4 in first row,2,5 in second row.BELOW select statement wont work for that.
SELECT LISTMEMBER FROM SysAdmin.fnSplitComma(SELECT IMPLanguages FROM CFI.InstructionalMediaPackage WHERE IMPLanguages=p.pkLanguageID) AS
&#039;nameList&#039;
FROM SysAdmin.M_Lang AS p]]></description>
		<content:encoded><![CDATA[<p>HOW TO USE SELECT STATEMENTS INSTEAD OF ARGUMENTS IN SPLIT COMMA FUNCTION incase of ms sql 2008 server?it returns value for the below query</p>
<p>select LISTMEMBER from SysAdmin.fnSplitComma (&#8217;2,3,5&#8242;)</p>
<p>like LISTMEMBER<br />
       2<br />
       3<br />
       5<br />
but how to get the value when we specifies a column in table which has data in the format 2,3,4 in first row,2,5 in second row.BELOW select statement wont work for that.<br />
SELECT LISTMEMBER FROM SysAdmin.fnSplitComma(SELECT IMPLanguages FROM CFI.InstructionalMediaPackage WHERE IMPLanguages=p.pkLanguageID) AS<br />
&#8216;nameList&#8217;<br />
FROM SysAdmin.M_Lang AS p</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SShirsat</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-212029</link>
		<dc:creator><![CDATA[SShirsat]]></dc:creator>
		<pubDate>Tue, 06 Dec 2011 11:46:21 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-212029</guid>
		<description><![CDATA[Got solution? I am also having same problem...]]></description>
		<content:encoded><![CDATA[<p>Got solution? I am also having same problem&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SShirsat</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-212027</link>
		<dc:creator><![CDATA[SShirsat]]></dc:creator>
		<pubDate>Tue, 06 Dec 2011 11:44:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-212027</guid>
		<description><![CDATA[@Mazharkhan

Did you find your answer..i have same problem..please revert]]></description>
		<content:encoded><![CDATA[<p>@Mazharkhan</p>
<p>Did you find your answer..i have same problem..please revert</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vyshu</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-207842</link>
		<dc:creator><![CDATA[vyshu]]></dc:creator>
		<pubDate>Wed, 30 Nov 2011 08:32:20 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-207842</guid>
		<description><![CDATA[hi
i want to separate the values given in a single row separeted by comma into multiple row..

for eg
Input : ab,bc,cd,de

output:
ab
bc
cd
de]]></description>
		<content:encoded><![CDATA[<p>hi<br />
i want to separate the values given in a single row separeted by comma into multiple row..</p>
<p>for eg<br />
Input : ab,bc,cd,de</p>
<p>output:<br />
ab<br />
bc<br />
cd<br />
de</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vyshu</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-207840</link>
		<dc:creator><![CDATA[vyshu]]></dc:creator>
		<pubDate>Wed, 30 Nov 2011 08:30:32 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-207840</guid>
		<description><![CDATA[hi
did u get this query.]]></description>
		<content:encoded><![CDATA[<p>hi<br />
did u get this query.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-197290</link>
		<dc:creator><![CDATA[Steve]]></dc:creator>
		<pubDate>Wed, 16 Nov 2011 23:47:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-197290</guid>
		<description><![CDATA[Hi Pinal Dave,

I have referenced this code many times. I appreciate you maintaining this site. Nicely done!

-Steve]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal Dave,</p>
<p>I have referenced this code many times. I appreciate you maintaining this site. Nicely done!</p>
<p>-Steve</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashant</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-181116</link>
		<dc:creator><![CDATA[Prashant]]></dc:creator>
		<pubDate>Thu, 20 Oct 2011 09:50:58 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-181116</guid>
		<description><![CDATA[Hi pinaldave,

 The code is help me a lot in one of my project.
  I really appreciate.

Thanks &amp; Regards,
Prashant Kauthekar]]></description>
		<content:encoded><![CDATA[<p>Hi pinaldave,</p>
<p> The code is help me a lot in one of my project.<br />
  I really appreciate.</p>
<p>Thanks &amp; Regards,<br />
Prashant Kauthekar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-175332</link>
		<dc:creator><![CDATA[Peter]]></dc:creator>
		<pubDate>Wed, 05 Oct 2011 10:36:56 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-175332</guid>
		<description><![CDATA[Can someone please help me? I have a column of string data collected from a survey. e.g. (Yes; No; Maybe; Don&#039;t know), assigned to a number of respondents. I want to create a list in a seperate COLUMN (retaining a Response heading) for each respondent. i.e.

Respondent       Response
A                          Yes
A                          No                    
A                          Yes
B                          Maybe
B                          No                    
B                          Yes]]></description>
		<content:encoded><![CDATA[<p>Can someone please help me? I have a column of string data collected from a survey. e.g. (Yes; No; Maybe; Don&#8217;t know), assigned to a number of respondents. I want to create a list in a seperate COLUMN (retaining a Response heading) for each respondent. i.e.</p>
<p>Respondent       Response<br />
A                          Yes<br />
A                          No<br />
A                          Yes<br />
B                          Maybe<br />
B                          No<br />
B                          Yes</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-167972</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 14 Sep 2011 09:53:29 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-167972</guid>
		<description><![CDATA[In the toolbar Goto Query--&gt;Query options--&gt;Results--Text . Select output format as comma delimited

Now set the result mode to text and run the query]]></description>
		<content:encoded><![CDATA[<p>In the toolbar Goto Query&#8211;&gt;Query options&#8211;&gt;Results&#8211;Text . Select output format as comma delimited</p>
<p>Now set the result mode to text and run the query</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajesh</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-167912</link>
		<dc:creator><![CDATA[Rajesh]]></dc:creator>
		<pubDate>Wed, 14 Sep 2011 03:29:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-167912</guid>
		<description><![CDATA[I want help with sql statment. when I select the data I get is like this

1 2232 eq233 1000  12-12-2011 11:11 39   9.2  text text

I want this output to have comma instead of space like

1, 2232, eq233, 1000, 12-12-2011 11:11, 39, 9.2, text text, 

can some please help.]]></description>
		<content:encoded><![CDATA[<p>I want help with sql statment. when I select the data I get is like this</p>
<p>1 2232 eq233 1000  12-12-2011 11:11 39   9.2  text text</p>
<p>I want this output to have comma instead of space like</p>
<p>1, 2232, eq233, 1000, 12-12-2011 11:11, 39, 9.2, text text, </p>
<p>can some please help.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kishor singh</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-167367</link>
		<dc:creator><![CDATA[kishor singh]]></dc:creator>
		<pubDate>Mon, 12 Sep 2011 03:29:10 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-167367</guid>
		<description><![CDATA[--create or replace function getAuthor(i_deptNo VARCHAR)
--  return VARCHAR(4000)
--  is
--    cursor c_emp is
--        select first_Name from employee where id = i_deptNo;
--      v_out VARCHAR2(4000);
--  begin
--      for r_emp in c_emp loop
--          if v_out is null then
--              v_out:=r_emp.first_Name;
--          else
--              v_out:=v_out&#124;&#124;&#039;, &#039;&#124;&#124;r_emp.first_Name;
--          end if;
--      end loop;
--      return v_out;
--  end


Try it !!!

Kishor singh]]></description>
		<content:encoded><![CDATA[<p>&#8211;create or replace function getAuthor(i_deptNo VARCHAR)<br />
&#8211;  return VARCHAR(4000)<br />
&#8211;  is<br />
&#8211;    cursor c_emp is<br />
&#8211;        select first_Name from employee where id = i_deptNo;<br />
&#8211;      v_out VARCHAR2(4000);<br />
&#8211;  begin<br />
&#8211;      for r_emp in c_emp loop<br />
&#8211;          if v_out is null then<br />
&#8211;              v_out:=r_emp.first_Name;<br />
&#8211;          else<br />
&#8211;              v_out:=v_out||&#8217;, &#8216;||r_emp.first_Name;<br />
&#8211;          end if;<br />
&#8211;      end loop;<br />
&#8211;      return v_out;<br />
&#8211;  end</p>
<p>Try it !!!</p>
<p>Kishor singh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: falguni</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-152288</link>
		<dc:creator><![CDATA[falguni]]></dc:creator>
		<pubDate>Mon, 01 Aug 2011 11:31:01 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-152288</guid>
		<description><![CDATA[Hi Pinal,
             I have taken one variable named @Period_List As varchar(max). I have set its vale as
            @Period_List = &#039;column1 int, column2 int, column 3&#039;
Now i am trying to create table using this variable,
Like,
        CREATE Table #TempTable (@Period_List)
But it gives error. can you please tell me another way or solution for this problem.]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
             I have taken one variable named @Period_List As varchar(max). I have set its vale as<br />
            @Period_List = &#8216;column1 int, column2 int, column 3&#8242;<br />
Now i am trying to create table using this variable,<br />
Like,<br />
        CREATE Table #TempTable (@Period_List)<br />
But it gives error. can you please tell me another way or solution for this problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anye</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-147788</link>
		<dc:creator><![CDATA[anye]]></dc:creator>
		<pubDate>Tue, 12 Jul 2011 21:50:17 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-147788</guid>
		<description><![CDATA[This script doesn&#039;t work if there are any null values in the set of rows being composited.

Try this instead: 

DECLARE @List VARCHAR(5000)
SELECT @List = COALESCE(@List + &#039;, &#039; +  MyField,  MyField)
FROM MyTable
select @List as MyDisplayName 

(from http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/289/creating-comma-separated-list-in-sql.aspx)

Only slightly different but more robust]]></description>
		<content:encoded><![CDATA[<p>This script doesn&#8217;t work if there are any null values in the set of rows being composited.</p>
<p>Try this instead: </p>
<p>DECLARE @List VARCHAR(5000)<br />
SELECT @List = COALESCE(@List + &#8216;, &#8216; +  MyField,  MyField)<br />
FROM MyTable<br />
select @List as MyDisplayName </p>
<p>(from <a href="http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/289/creating-comma-separated-list-in-sql.aspx" rel="nofollow">http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/289/creating-comma-separated-list-in-sql.aspx</a>)</p>
<p>Only slightly different but more robust</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Butt</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-141092</link>
		<dc:creator><![CDATA[Butt]]></dc:creator>
		<pubDate>Wed, 15 Jun 2011 15:31:01 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-141092</guid>
		<description><![CDATA[Pinal,
How can I use this comma separated list in a query? like where value IN ( Select commaSeparatedList from MyTable)]]></description>
		<content:encoded><![CDATA[<p>Pinal,<br />
How can I use this comma separated list in a query? like where value IN ( Select commaSeparatedList from MyTable)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HV</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-136275</link>
		<dc:creator><![CDATA[HV]]></dc:creator>
		<pubDate>Mon, 23 May 2011 21:26:06 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-136275</guid>
		<description><![CDATA[If I want this view would COALESCE work?  How else can I get this please?


Data - All in one table
Col1          Col2
------        ----------
USA         Denver
USA         Seattle
USA         Chicago
Canada    Vancouver
Canada    Calgary

Result - 

Col1         Col2
-----         -----------
USA          Denver, Seattle, Chicago
Canada      Vancouver, Calgary]]></description>
		<content:encoded><![CDATA[<p>If I want this view would COALESCE work?  How else can I get this please?</p>
<p>Data &#8211; All in one table<br />
Col1          Col2<br />
&#8212;&#8212;        &#8212;&#8212;&#8212;-<br />
USA         Denver<br />
USA         Seattle<br />
USA         Chicago<br />
Canada    Vancouver<br />
Canada    Calgary</p>
<p>Result &#8211; </p>
<p>Col1         Col2<br />
&#8212;&#8211;         &#8212;&#8212;&#8212;&#8211;<br />
USA          Denver, Seattle, Chicago<br />
Canada      Vancouver, Calgary</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-133825</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Tue, 10 May 2011 13:22:55 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-133825</guid>
		<description><![CDATA[Search for rowset concatenation in this site]]></description>
		<content:encoded><![CDATA[<p>Search for rowset concatenation in this site</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hugo</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-133576</link>
		<dc:creator><![CDATA[Hugo]]></dc:creator>
		<pubDate>Mon, 09 May 2011 09:58:13 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-133576</guid>
		<description><![CDATA[Hi!

I have a query like this:

InvoiceNum                Depart.
---------------               --------------
11000                        400
11000                        404
15000                        572

And I need:

InvoiceNum                Depart.
---------------               --------------
11000                        400, 404
15000                        572

Is it possible? Thanks!!!!]]></description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>I have a query like this:</p>
<p>InvoiceNum                Depart.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;               &#8212;&#8212;&#8212;&#8212;&#8211;<br />
11000                        400<br />
11000                        404<br />
15000                        572</p>
<p>And I need:</p>
<p>InvoiceNum                Depart.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;               &#8212;&#8212;&#8212;&#8212;&#8211;<br />
11000                        400, 404<br />
15000                        572</p>
<p>Is it possible? Thanks!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Udayaa</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-131949</link>
		<dc:creator><![CDATA[Udayaa]]></dc:creator>
		<pubDate>Fri, 29 Apr 2011 11:42:09 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-131949</guid>
		<description><![CDATA[Hi Pinal,

Can I use COALESCE in update statement ?

when I am trying to update the rows to temp table the concatenation doesn&#039;t happen.
It picks only the first value
Please help

Create Table #TempData
(
	Pe_Logn Varchar(10), Team Varchar(8000)
)

Insert Into #TempData
Select Distinct(PE_DEPT), NULL from iP_Person

/* Select *from #TempDate */
Pe_Logn      Team
Finance      NULL 
HR           NULL 
IT           NULL

/* Getting the people for each department */
Update #TempData
Set Team = COALESCE(IsNull(TEAM, &#039;&#039;) + &#039;,&#039;,&#039;&#039;) + Pe.Pe_Logn from iP_Person Pe
Where Pe.Pe_Dept = #TempData.Pe_Logn

/* Select *from #TempData */
Pe_Logn      Team
Finance      ,ABC
HR           ,DEF
IT           ,XYZ

Actual output should have been 
Pe_Logn      Team
Finance      ,ABC, 123, !@#
HR           ,DEF, 234, @#$
IT           ,XYZ, 345, #$%

Regards,
Uday]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>Can I use COALESCE in update statement ?</p>
<p>when I am trying to update the rows to temp table the concatenation doesn&#8217;t happen.<br />
It picks only the first value<br />
Please help</p>
<p>Create Table #TempData<br />
(<br />
	Pe_Logn Varchar(10), Team Varchar(8000)<br />
)</p>
<p>Insert Into #TempData<br />
Select Distinct(PE_DEPT), NULL from iP_Person</p>
<p>/* Select *from #TempDate */<br />
Pe_Logn      Team<br />
Finance      NULL<br />
HR           NULL<br />
IT           NULL</p>
<p>/* Getting the people for each department */<br />
Update #TempData<br />
Set Team = COALESCE(IsNull(TEAM, &#8221;) + &#8216;,&#8217;,&#8221;) + Pe.Pe_Logn from iP_Person Pe<br />
Where Pe.Pe_Dept = #TempData.Pe_Logn</p>
<p>/* Select *from #TempData */<br />
Pe_Logn      Team<br />
Finance      ,ABC<br />
HR           ,DEF<br />
IT           ,XYZ</p>
<p>Actual output should have been<br />
Pe_Logn      Team<br />
Finance      ,ABC, 123, !@#<br />
HR           ,DEF, 234, @#$<br />
IT           ,XYZ, 345, #$%</p>
<p>Regards,<br />
Uday</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-129486</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Mon, 18 Apr 2011 10:19:02 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-129486</guid>
		<description><![CDATA[Refer this
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<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: nidhi</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-129472</link>
		<dc:creator><![CDATA[nidhi]]></dc:creator>
		<pubDate>Mon, 18 Apr 2011 09:18:26 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-129472</guid>
		<description><![CDATA[I have two tables (please note that column headers are dynamic - not necessarily 3 or 4 columns..but the same numbr of records will be present in the column data):

Table 1: 

SortSeqID            ColumnHeader 
1	           ‘ColA,ColB,ColC’
2	           ‘ColA,ColB,ColC,ColD’
3	            ‘ColA,ColC,ColD’


Table 2:
SortSeqID            ColumnData
1               	‘1,2,3’
2	                ’11,13,243,5’
3              	‘1,5,6’



Need output like:
SortSeqID          ColA       ColB       ColC       ColD
1                         1              2              3              
2                         11           13           243         5
3                        1                              5              6]]></description>
		<content:encoded><![CDATA[<p>I have two tables (please note that column headers are dynamic &#8211; not necessarily 3 or 4 columns..but the same numbr of records will be present in the column data):</p>
<p>Table 1: </p>
<p>SortSeqID            ColumnHeader<br />
1	           ‘ColA,ColB,ColC’<br />
2	           ‘ColA,ColB,ColC,ColD’<br />
3	            ‘ColA,ColC,ColD’</p>
<p>Table 2:<br />
SortSeqID            ColumnData<br />
1               	‘1,2,3’<br />
2	                ’11,13,243,5’<br />
3              	‘1,5,6’</p>
<p>Need output like:<br />
SortSeqID          ColA       ColB       ColC       ColD<br />
1                         1              2              3<br />
2                         11           13           243         5<br />
3                        1                              5              6</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amrish</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-125938</link>
		<dc:creator><![CDATA[Amrish]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 07:17:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-125938</guid>
		<description><![CDATA[Hi Pinal,
     I got the solution for Select Distinct

but i don&#039;t know about SQL Server 2005 but it is working in SQL Server 2008

USE AdventureWorks
GO
DECLARE @listStr XML
set @listStr=(SELECT DISTINCT  COALESCE( Name,&#039;&#039;)+&#039;,&#039;
FROM Production.Product
for XML Path(&#039;&#039;))

SELECT SUBSTRING(CAST (@ listStr  AS VARCHAR) , 1, LEN(CAST (@ listStr  AS VARCHAR))-1)
GO]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,<br />
     I got the solution for Select Distinct</p>
<p>but i don&#8217;t know about SQL Server 2005 but it is working in SQL Server 2008</p>
<p>USE AdventureWorks<br />
GO<br />
DECLARE @listStr XML<br />
set @listStr=(SELECT DISTINCT  COALESCE( Name,&#8221;)+&#8217;,&#8217;<br />
FROM Production.Product<br />
for XML Path(&#8221;))</p>
<p>SELECT SUBSTRING(CAST (@ listStr  AS VARCHAR) , 1, LEN(CAST (@ listStr  AS VARCHAR))-1)<br />
GO</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amrish</title>
		<link>http://blog.sqlauthority.com/2008/06/04/sql-server-create-a-comma-delimited-list-using-select-clause-from-table-column/#comment-125931</link>
		<dc:creator><![CDATA[Amrish]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 06:55:27 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=631#comment-125931</guid>
		<description><![CDATA[Hi Pinal,

I want this in Select distinct query result.

It is not working in case of distinct

I have tried like following and i didn&#039;t get desired result

USE AdventureWorks
GO
DECLARE @listStr VARCHAR(MAX)
SELECT DISTINCT @listStr = COALESCE(@listStr+&#039;,&#039; ,&#039;&#039;) + Name
FROM Production.Product
SELECT @listStr
GO

Plz give some solution]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I want this in Select distinct query result.</p>
<p>It is not working in case of distinct</p>
<p>I have tried like following and i didn&#8217;t get desired result</p>
<p>USE AdventureWorks<br />
GO<br />
DECLARE @listStr VARCHAR(MAX)<br />
SELECT DISTINCT @listStr = COALESCE(@listStr+&#8217;,&#8217; ,&#8221;) + Name<br />
FROM Production.Product<br />
SELECT @listStr<br />
GO</p>
<p>Plz give some solution</p>
]]></content:encoded>
	</item>
</channel>
</rss>

