<?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; UDF &#8211; Function to Convert List to Table</title>
	<atom:link href="http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #028 &#124; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-472972</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #028 &#124; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 11 May 2013 01:30:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-472972</guid>
		<description><![CDATA[[&#8230;] UDF – Function to Convert List to Table Article contains UDF written for SQL SERVER 2005. It will also work well with the very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. It will convert the list to table. [&#8230;]]]></description>
		<content:encoded><![CDATA[<p>[&#8230;] UDF – Function to Convert List to Table Article contains UDF written for SQL SERVER 2005. It will also work well with the very big TEXT field. If you want to use this on SQL SERVER 2000 replace VARCHAR(MAX) with VARCHAR(8000) or any other varchar limit. It will work with INT as well as VARCHAR. It will convert the list to table. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-336285</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Thu, 23 Aug 2012 12:41:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-336285</guid>
		<description><![CDATA[What did you mean by NULL values?]]></description>
		<content:encoded><![CDATA[<p>What did you mean by NULL values?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sudhakar</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-324494</link>
		<dc:creator><![CDATA[sudhakar]]></dc:creator>
		<pubDate>Fri, 03 Aug 2012 23:58:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-324494</guid>
		<description><![CDATA[Dear Pinal,

Could you please tell us how to retrieve the null  values 
Ex:  1 st row   12,43,12,65
       2 nd row   null
        3 rd row   67,1,14
result set should be like  12
                                        43
                                        12
                                         65
                                          null
                                         67
                                          1
                                          14

I have tried in below  but in vain  

DECLARE @commaSeparatedVal AS varchar(max);

SELECT @commaSeparatedVal =  @commaSeparatedVal +&#039;,&#039;+ null + CONVERT(varchar,sourcelangid)  FROM ProjectSummaries
PRINT @commaSeparatedVal

select cast(item as varchar) as sudha from  dbo.udf_List2Table (@commaSeparatedVal ,&#039;,&#039;)]]></description>
		<content:encoded><![CDATA[<p>Dear Pinal,</p>
<p>Could you please tell us how to retrieve the null  values<br />
Ex:  1 st row   12,43,12,65<br />
       2 nd row   null<br />
        3 rd row   67,1,14<br />
result set should be like  12<br />
                                        43<br />
                                        12<br />
                                         65<br />
                                          null<br />
                                         67<br />
                                          1<br />
                                          14</p>
<p>I have tried in below  but in vain  </p>
<p>DECLARE @commaSeparatedVal AS varchar(max);</p>
<p>SELECT @commaSeparatedVal =  @commaSeparatedVal +&#8217;,'+ null + CONVERT(varchar,sourcelangid)  FROM ProjectSummaries<br />
PRINT @commaSeparatedVal</p>
<p>select cast(item as varchar) as sudha from  dbo.udf_List2Table (@commaSeparatedVal ,&#8217;,')</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: varungaurv</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-238545</link>
		<dc:creator><![CDATA[varungaurv]]></dc:creator>
		<pubDate>Mon, 16 Jan 2012 08:58:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-238545</guid>
		<description><![CDATA[thanks a lot pinal.]]></description>
		<content:encoded><![CDATA[<p>thanks a lot pinal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yashpal Shah</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-180233</link>
		<dc:creator><![CDATA[Yashpal Shah]]></dc:creator>
		<pubDate>Tue, 18 Oct 2011 06:44:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-180233</guid>
		<description><![CDATA[Hi RG, 

I think your solution will fail in cases where there are values like 34,134,3,4
Please check and confirm.

Thanks,
Yashpal.]]></description>
		<content:encoded><![CDATA[<p>Hi RG, </p>
<p>I think your solution will fail in cases where there are values like 34,134,3,4<br />
Please check and confirm.</p>
<p>Thanks,<br />
Yashpal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael L. Newman Jr.</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-136583</link>
		<dc:creator><![CDATA[Michael L. Newman Jr.]]></dc:creator>
		<pubDate>Wed, 25 May 2011 11:38:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-136583</guid>
		<description><![CDATA[Good Post!]]></description>
		<content:encoded><![CDATA[<p>Good Post!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gitesh</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-101787</link>
		<dc:creator><![CDATA[Gitesh]]></dc:creator>
		<pubDate>Wed, 24 Nov 2010 04:07:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-101787</guid>
		<description><![CDATA[HI.
Is there any other way to do this same thing..? i mean any fast way without Loop.. coz if our string is too long then it effects performance.]]></description>
		<content:encoded><![CDATA[<p>HI.<br />
Is there any other way to do this same thing..? i mean any fast way without Loop.. coz if our string is too long then it effects performance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Balázs Kisgadó</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-94447</link>
		<dc:creator><![CDATA[Balázs Kisgadó]]></dc:creator>
		<pubDate>Wed, 20 Oct 2010 14:27:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-94447</guid>
		<description><![CDATA[Hello,

I am new to SQL and I am looking for a solution for the opposite situation. I have a table, but I need a string that contains each elemont of one column of my table.

Do you have a script for that?

Thanks,
Balázs]]></description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>I am new to SQL and I am looking for a solution for the opposite situation. I have a table, but I need a string that contains each elemont of one column of my table.</p>
<p>Do you have a script for that?</p>
<p>Thanks,<br />
Balázs</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-58663</link>
		<dc:creator><![CDATA[Pinal Dave]]></dc:creator>
		<pubDate>Tue, 15 Dec 2009 14:45:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-58663</guid>
		<description><![CDATA[Hi,

Option 2 is better because function is not used in subquery. 
Option 1 has a lot of overhead.
After all the best is one that pass testing.

Regards,
Pinal Dave]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Option 2 is better because function is not used in subquery.<br />
Option 1 has a lot of overhead.<br />
After all the best is one that pass testing.</p>
<p>Regards,<br />
Pinal Dave</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RG</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-58646</link>
		<dc:creator><![CDATA[RG]]></dc:creator>
		<pubDate>Tue, 15 Dec 2009 06:58:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-58646</guid>
		<description><![CDATA[Hi Pinal,

I would like to know which method out of these two options is the best ,

(option 1)
select c1,
from t1
where t1.c2 in (select cast(item as int) from dbo.udf_List2Table(&#039;123,453,34&#039;,&#039;,&#039;))

or
(option 2)
select c1
from t1
where charindex(t1.c2,&#039;123,453,34&#039;) &gt; 0

as per my understanding , option 2 will supress index usage and will slow the query down when data load is high on t1 table. it force index or table scans as well. Am I correct here or is there more to this ?

Thanks,
RG]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal,</p>
<p>I would like to know which method out of these two options is the best ,</p>
<p>(option 1)<br />
select c1,<br />
from t1<br />
where t1.c2 in (select cast(item as int) from dbo.udf_List2Table(&#8217;123,453,34&#8242;,&#8217;,'))</p>
<p>or<br />
(option 2)<br />
select c1<br />
from t1<br />
where charindex(t1.c2,&#8217;123,453,34&#8242;) &gt; 0</p>
<p>as per my understanding , option 2 will supress index usage and will slow the query down when data load is high on t1 table. it force index or table scans as well. Am I correct here or is there more to this ?</p>
<p>Thanks,<br />
RG</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-54820</link>
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Thu, 13 Aug 2009 12:49:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-54820</guid>
		<description><![CDATA[Thank you for this!  It really was useful for me, as I wanted to be able to return an Max and a Sum of a group for items that were being calculated, appearing in a single row. 

I changed your function to have the Item be a float, and  then used the convert function to pass the variables in:

Select Val1, Val2, Val3, Val4, 
(
Select Max(Item) From dbo.udf_List2Table(Convert(varchar(20),Val1) + &#039;,&#039; + Convert(varchar(20),Val2) + &#039;,&#039; +  + Convert(varchar(20),Val3) + &#039;,&#039; +  + Convert(varchar(20),val4) + &#039;,&#039;,&#039;,&#039;)
) as MaxVal
From tbl]]></description>
		<content:encoded><![CDATA[<p>Thank you for this!  It really was useful for me, as I wanted to be able to return an Max and a Sum of a group for items that were being calculated, appearing in a single row. </p>
<p>I changed your function to have the Item be a float, and  then used the convert function to pass the variables in:</p>
<p>Select Val1, Val2, Val3, Val4,<br />
(<br />
Select Max(Item) From dbo.udf_List2Table(Convert(varchar(20),Val1) + &#8216;,&#8217; + Convert(varchar(20),Val2) + &#8216;,&#8217; +  + Convert(varchar(20),Val3) + &#8216;,&#8217; +  + Convert(varchar(20),val4) + &#8216;,&#8217;,',&#8217;)<br />
) as MaxVal<br />
From tbl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: phani</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-54394</link>
		<dc:creator><![CDATA[phani]]></dc:creator>
		<pubDate>Mon, 03 Aug 2009 15:41:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-54394</guid>
		<description><![CDATA[Thanks a ton Dave, I have got stupid extension for more lists of csv into single table :)
CREATE FUNCTION dbo.udf_Lists2Table
(
@List1 VARCHAR(MAX),
@List2 VARCHAR(MAX),
@List3 VARCHAR(MAX),
@Delim CHAR
)
RETURNS
@ParsedList TABLE
(
item1 VARCHAR(MAX),
item2 VARCHAR(MAX),
item3 VARCHAR(MAX)
)
AS
BEGIN
DECLARE @item1 VARCHAR(MAX), @Pos1 INT,
@item2 VARCHAR(MAX), @Pos2 INT,
@item3 VARCHAR(MAX), @Pos3 INT
SET @List1 = LTRIM(RTRIM(@List1))+ @Delim
SET @List2 = LTRIM(RTRIM(@List2))+ @Delim
SET @List3 = LTRIM(RTRIM(@List3))+ @Delim
SET @Pos1 = CHARINDEX(@Delim, @List1, 1)
SET @Pos2 = CHARINDEX(@Delim, @List2, 1)
SET @Pos3 = CHARINDEX(@Delim, @List3, 1)
WHILE (@Pos1 &gt; 0 AND @Pos2 &gt; 0 AND @Pos2 &gt; 0)
BEGIN
SET @item1 = LTRIM(RTRIM(LEFT(@List1, @Pos1 - 1)))
SET @item2 = LTRIM(RTRIM(LEFT(@List2, @Pos2 - 1)))
SET @item3 = LTRIM(RTRIM(LEFT(@List3, @Pos3 - 1)))
IF @item1 = &#039;&#039;
BEGIN
 SET @item1 = NULL
END
IF @item2 = &#039;&#039;
BEGIN
 SET @item2 = NULL
END
IF @item3 = &#039;&#039;
BEGIN
 SET @item3 = NULL
END
INSERT INTO @ParsedList (item1, item2, item3)
VALUES (CAST(@item1 AS VARCHAR(MAX)), CAST(@item2 AS VARCHAR(MAX)), CAST(@item3 AS VARCHAR(MAX)))
SET @List1 = RIGHT(@List1, LEN(@List1) - @Pos1)
SET @List2 = RIGHT(@List2, LEN(@List2) - @Pos2)
SET @List3 = RIGHT(@List3, LEN(@List3) - @Pos3)
SET @Pos1 = CHARINDEX(@Delim, @List1, 1)
SET @Pos2 = CHARINDEX(@Delim, @List2, 1)
SET @Pos3 = CHARINDEX(@Delim, @List3, 1)
END
RETURN
END
GO

select * from udf_List2Table(&#039;1, ,3&#039;,&#039;a,b,c&#039;,&#039;x, ,z&#039;, &#039;,&#039;)]]></description>
		<content:encoded><![CDATA[<p>Thanks a ton Dave, I have got stupid extension for more lists of csv into single table :)<br />
CREATE FUNCTION dbo.udf_Lists2Table<br />
(<br />
@List1 VARCHAR(MAX),<br />
@List2 VARCHAR(MAX),<br />
@List3 VARCHAR(MAX),<br />
@Delim CHAR<br />
)<br />
RETURNS<br />
@ParsedList TABLE<br />
(<br />
item1 VARCHAR(MAX),<br />
item2 VARCHAR(MAX),<br />
item3 VARCHAR(MAX)<br />
)<br />
AS<br />
BEGIN<br />
DECLARE @item1 VARCHAR(MAX), @Pos1 INT,<br />
@item2 VARCHAR(MAX), @Pos2 INT,<br />
@item3 VARCHAR(MAX), @Pos3 INT<br />
SET @List1 = LTRIM(RTRIM(@List1))+ @Delim<br />
SET @List2 = LTRIM(RTRIM(@List2))+ @Delim<br />
SET @List3 = LTRIM(RTRIM(@List3))+ @Delim<br />
SET @Pos1 = CHARINDEX(@Delim, @List1, 1)<br />
SET @Pos2 = CHARINDEX(@Delim, @List2, 1)<br />
SET @Pos3 = CHARINDEX(@Delim, @List3, 1)<br />
WHILE (@Pos1 &gt; 0 AND @Pos2 &gt; 0 AND @Pos2 &gt; 0)<br />
BEGIN<br />
SET @item1 = LTRIM(RTRIM(LEFT(@List1, @Pos1 &#8211; 1)))<br />
SET @item2 = LTRIM(RTRIM(LEFT(@List2, @Pos2 &#8211; 1)))<br />
SET @item3 = LTRIM(RTRIM(LEFT(@List3, @Pos3 &#8211; 1)))<br />
IF @item1 = &#8221;<br />
BEGIN<br />
 SET @item1 = NULL<br />
END<br />
IF @item2 = &#8221;<br />
BEGIN<br />
 SET @item2 = NULL<br />
END<br />
IF @item3 = &#8221;<br />
BEGIN<br />
 SET @item3 = NULL<br />
END<br />
INSERT INTO @ParsedList (item1, item2, item3)<br />
VALUES (CAST(@item1 AS VARCHAR(MAX)), CAST(@item2 AS VARCHAR(MAX)), CAST(@item3 AS VARCHAR(MAX)))<br />
SET @List1 = RIGHT(@List1, LEN(@List1) &#8211; @Pos1)<br />
SET @List2 = RIGHT(@List2, LEN(@List2) &#8211; @Pos2)<br />
SET @List3 = RIGHT(@List3, LEN(@List3) &#8211; @Pos3)<br />
SET @Pos1 = CHARINDEX(@Delim, @List1, 1)<br />
SET @Pos2 = CHARINDEX(@Delim, @List2, 1)<br />
SET @Pos3 = CHARINDEX(@Delim, @List3, 1)<br />
END<br />
RETURN<br />
END<br />
GO</p>
<p>select * from udf_List2Table(&#8217;1, ,3&#8242;,&#8217;a,b,c&#8217;,'x, ,z&#8217;, &#8216;,&#8217;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Function to Convert List to Table Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-45765</link>
		<dc:creator><![CDATA[SQL SERVER - Function to Convert List to Table Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Tue, 20 Jan 2009 07:43:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-45765</guid>
		<description><![CDATA[[...] February 10, 2007 by pinaldave    Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005.  Visit :SQL SERVER - UDF - Function to Convert List to Table [...]]]></description>
		<content:encoded><![CDATA[<p>[...] February 10, 2007 by pinaldave    Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005.  Visit :SQL SERVER &#8211; UDF &#8211; Function to Convert List to Table [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Function to Convert List to Table Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-45742</link>
		<dc:creator><![CDATA[SQL SERVER - Function to Convert List to Table Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Mon, 19 Jan 2009 19:05:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-45742</guid>
		<description><![CDATA[[...] February 10, 2007 by pinaldave    Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005.  Visit :SQL SERVER - UDF - Function to Convert List to Table [...]]]></description>
		<content:encoded><![CDATA[<p>[...] February 10, 2007 by pinaldave    Update : (5/5/2007) I have updated the UDF to support SQL SERVER 2005.  Visit :SQL SERVER &#8211; UDF &#8211; Function to Convert List to Table [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ad</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-41626</link>
		<dc:creator><![CDATA[Ad]]></dc:creator>
		<pubDate>Tue, 12 Aug 2008 23:48:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-41626</guid>
		<description><![CDATA[I am relatively new to SQL, this code from Sudev gandhi works great, but can someone please explain how this works...

DECLARE @commaSeparatedVal AS VARCHAR(MAX);
SELECT @commaSeparatedVal = ISNULL(@commaSeparatedVal +’,&#039;,”) + CONVERT(VARCHAR,[SKU]) FROM PRODUCT
PRINT @commaSeparatedVal]]></description>
		<content:encoded><![CDATA[<p>I am relatively new to SQL, this code from Sudev gandhi works great, but can someone please explain how this works&#8230;</p>
<p>DECLARE @commaSeparatedVal AS VARCHAR(MAX);<br />
SELECT @commaSeparatedVal = ISNULL(@commaSeparatedVal +’,&#8217;,”) + CONVERT(VARCHAR,[SKU]) FROM PRODUCT<br />
PRINT @commaSeparatedVal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sudev Gandhi</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-38887</link>
		<dc:creator><![CDATA[Sudev Gandhi]]></dc:creator>
		<pubDate>Fri, 30 May 2008 10:58:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-38887</guid>
		<description><![CDATA[Hi Jayaram &amp; HAGster,

I guess what you people need is from a table you need to combine all the values in single field e.g. from PRODUCT table you want list of [SKU] column in &#039;,&#039; separated list. for that you can use following T-SQL snippet.

    DECLARE @commaSeparatedVal AS VARCHAR(MAX);
    SELECT @commaSeparatedVal = ISNULL(@commaSeparatedVal +&#039;,&#039;,&#039;&#039;) + CONVERT(VARCHAR,[SKU]) FROM PRODUCT
    PRINT @commaSeparatedVal

Now you can fire

SELECT CAST(item AS INT) AS Example2
FROM dbo.udf_List2Table(@commaSeparatedVal,’,&#039;)

ref: http://sudev.blogspot.com/2008/05/comma-separated-list-of-values-of.html]]></description>
		<content:encoded><![CDATA[<p>Hi Jayaram &amp; HAGster,</p>
<p>I guess what you people need is from a table you need to combine all the values in single field e.g. from PRODUCT table you want list of [SKU] column in &#8216;,&#8217; separated list. for that you can use following T-SQL snippet.</p>
<p>    DECLARE @commaSeparatedVal AS VARCHAR(MAX);<br />
    SELECT @commaSeparatedVal = ISNULL(@commaSeparatedVal +&#8217;,',&#8221;) + CONVERT(VARCHAR,[SKU]) FROM PRODUCT<br />
    PRINT @commaSeparatedVal</p>
<p>Now you can fire</p>
<p>SELECT CAST(item AS INT) AS Example2<br />
FROM dbo.udf_List2Table(@commaSeparatedVal,’,&#8217;)</p>
<p>ref: <a href="http://sudev.blogspot.com/2008/05/comma-separated-list-of-values-of.html" rel="nofollow">http://sudev.blogspot.com/2008/05/comma-separated-list-of-values-of.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HAGster</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-37624</link>
		<dc:creator><![CDATA[HAGster]]></dc:creator>
		<pubDate>Mon, 12 May 2008 14:58:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-37624</guid>
		<description><![CDATA[For Jamaram
Just in case your reading this Jamaram, I did a little work around to accomplish what you needed.
Declare a varable and select your comma separated list into in then run the function against the varable like below.

If this is any help then im glad, and im not very good at SQL so I have no idea if this is a messy way to do it etc.


Declare @yourlist char(800)
select @yourlist = (SELECT itemlist FROM tablename WHERE id = 1 )


SELECT item AS Example1
    FROM dbo.udf_List2Table(@yourlist,&#039;,&#039;)
GO


Kind Regards Guy]]></description>
		<content:encoded><![CDATA[<p>For Jamaram<br />
Just in case your reading this Jamaram, I did a little work around to accomplish what you needed.<br />
Declare a varable and select your comma separated list into in then run the function against the varable like below.</p>
<p>If this is any help then im glad, and im not very good at SQL so I have no idea if this is a messy way to do it etc.</p>
<p>Declare @yourlist char(800)<br />
select @yourlist = (SELECT itemlist FROM tablename WHERE id = 1 )</p>
<p>SELECT item AS Example1<br />
    FROM dbo.udf_List2Table(@yourlist,&#8217;,')<br />
GO</p>
<p>Kind Regards Guy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HAGster</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-37621</link>
		<dc:creator><![CDATA[HAGster]]></dc:creator>
		<pubDate>Mon, 12 May 2008 14:44:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-37621</guid>
		<description><![CDATA[Was woundering the same myself Jayaram, did you work out how to use the function against SELECTED data?

Kind Regards Guy]]></description>
		<content:encoded><![CDATA[<p>Was woundering the same myself Jayaram, did you work out how to use the function against SELECTED data?</p>
<p>Kind Regards Guy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jayaram</title>
		<link>http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-35232</link>
		<dc:creator><![CDATA[jayaram]]></dc:creator>
		<pubDate>Mon, 21 Apr 2008 08:25:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/05/06/sql-server-udf-function-to-convert-list-to-table/#comment-35232</guid>
		<description><![CDATA[Thanks !! It works fine with data passed as parameter...
But how to substitute a column name instead of the raw data in the UDF. I tried but in vain...   I mean...   

SELECT CAST(item AS INT) AS Example2
FROM dbo.udf_List2Table(select canview from table3,&#039;,&#039;)
GO

gives the error message. Incorrect syntax near &quot;select&quot;

pL help.!]]></description>
		<content:encoded><![CDATA[<p>Thanks !! It works fine with data passed as parameter&#8230;<br />
But how to substitute a column name instead of the raw data in the UDF. I tried but in vain&#8230;   I mean&#8230;   </p>
<p>SELECT CAST(item AS INT) AS Example2<br />
FROM dbo.udf_List2Table(select canview from table3,&#8217;,')<br />
GO</p>
<p>gives the error message. Incorrect syntax near &#8220;select&#8221;</p>
<p>pL help.!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
