<?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; Storing Variable Values in Temporary Array or Temporary List</title>
	<atom:link href="http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 24 May 2013 22:47:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Harsh</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-366926</link>
		<dc:creator><![CDATA[Harsh]]></dc:creator>
		<pubDate>Wed, 31 Oct 2012 08:09:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-366926</guid>
		<description><![CDATA[in above script, not equal sign is not displayed in last statement &amp; last union statement]]></description>
		<content:encoded><![CDATA[<p>in above script, not equal sign is not displayed in last statement &amp; last union statement</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harsh</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-366917</link>
		<dc:creator><![CDATA[Harsh]]></dc:creator>
		<pubDate>Wed, 31 Oct 2012 07:52:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-366917</guid>
		<description><![CDATA[We can also get a similar result using CTE

Declare @stringvar VARCHAR(max)
set @stringvar =  &#039;a,10,20,c,30,d&#039;;
with cte(IDs,stringvalue,id)
as
(
select cast(&#039;&#039; as VARCHAR(MAX)), @stringvar, 0 
union all 
select left(stringvalue,charindex(&#039;,&#039;,stringvalue,0)-1), right(stringvalue,len(stringvalue)-charindex(&#039;,&#039;,stringvalue,0)), id+1  from cte where charindex(&#039;,&#039;,stringvalue,0)&gt;0
union all
select stringvalue,&#039;&#039;, id+1 from cte where charindex(&#039;,&#039;,stringvalue,0)=0 and stringvalue&#039;&#039;
)
select IDs from cte where IDs&#039;&#039;]]></description>
		<content:encoded><![CDATA[<p>We can also get a similar result using CTE</p>
<p>Declare @stringvar VARCHAR(max)<br />
set @stringvar =  &#8216;a,10,20,c,30,d&#8217;;<br />
with cte(IDs,stringvalue,id)<br />
as<br />
(<br />
select cast(&#8221; as VARCHAR(MAX)), @stringvar, 0<br />
union all<br />
select left(stringvalue,charindex(&#8216;,&#8217;,stringvalue,0)-1), right(stringvalue,len(stringvalue)-charindex(&#8216;,&#8217;,stringvalue,0)), id+1  from cte where charindex(&#8216;,&#8217;,stringvalue,0)&gt;0<br />
union all<br />
select stringvalue,&#8221;, id+1 from cte where charindex(&#8216;,&#8217;,stringvalue,0)=0 and stringvalue&#8221;<br />
)<br />
select IDs from cte where IDs&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niraj Patil</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-366735</link>
		<dc:creator><![CDATA[Niraj Patil]]></dc:creator>
		<pubDate>Wed, 31 Oct 2012 02:11:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-366735</guid>
		<description><![CDATA[Hi Pinal ,
If values are stored in variable then how above script.works.
e.g: 
Declare @var NVARCHAR(max)
@var =  &#039;a,b,c,d&#039;]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal ,<br />
If values are stored in variable then how above script.works.<br />
e.g:<br />
Declare @var NVARCHAR(max)<br />
@var =  &#8216;a,b,c,d&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Girijesh Pandey</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-366502</link>
		<dc:creator><![CDATA[Girijesh Pandey]]></dc:creator>
		<pubDate>Tue, 30 Oct 2012 13:05:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-366502</guid>
		<description><![CDATA[Yes, it works only with SQL Server 2008 onwards.]]></description>
		<content:encoded><![CDATA[<p>Yes, it works only with SQL Server 2008 onwards.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kumar Harsh</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-365683</link>
		<dc:creator><![CDATA[Kumar Harsh]]></dc:creator>
		<pubDate>Sun, 28 Oct 2012 10:58:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-365683</guid>
		<description><![CDATA[If for multidatatype varchar is use then to manipulate those data ,one has to use isnumeric,isdate etc. and do manipulation,which is little lengthy process.Beside this one cannot find the exact other datatype beside these two isdate and isnumeric.So process is lengthy and complicated.

In case of Sql_variant,same thing is very easy.We can use sql_variant_property  to do so.

declare @t table(col1 sql_variant )
insert into @t values(1),(&#039;2&#039;)
Select sql_variant_property(col1, &#039;BaseType&#039;) from @t

vs

declare @t table(col1 varchar(100) )
insert into @t values(1),(&#039;2&#039;)
Select	sql_variant_property(col1, &#039;BaseType&#039;) from @t]]></description>
		<content:encoded><![CDATA[<p>If for multidatatype varchar is use then to manipulate those data ,one has to use isnumeric,isdate etc. and do manipulation,which is little lengthy process.Beside this one cannot find the exact other datatype beside these two isdate and isnumeric.So process is lengthy and complicated.</p>
<p>In case of Sql_variant,same thing is very easy.We can use sql_variant_property  to do so.</p>
<p>declare @t table(col1 sql_variant )<br />
insert into @t values(1),(&#8217;2&#8242;)<br />
Select sql_variant_property(col1, &#8216;BaseType&#8217;) from @t</p>
<p>vs</p>
<p>declare @t table(col1 varchar(100) )<br />
insert into @t values(1),(&#8217;2&#8242;)<br />
Select	sql_variant_property(col1, &#8216;BaseType&#8217;) from @t</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kumar Harsh</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-365675</link>
		<dc:creator><![CDATA[Kumar Harsh]]></dc:creator>
		<pubDate>Sun, 28 Oct 2012 10:43:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-365675</guid>
		<description><![CDATA[For multi datatype,one can use sql_variant datatype supported since 2000.
Though I have never use this.I read it has some limitation.
http://msdn.microsoft.com/en-us/library/aa223955%28v=sql.80%29.aspx

So when should i choose sql_variant over varchar ?what is the advantage of sql_variant ?]]></description>
		<content:encoded><![CDATA[<p>For multi datatype,one can use sql_variant datatype supported since 2000.<br />
Though I have never use this.I read it has some limitation.<br />
<a href="http://msdn.microsoft.com/en-us/library/aa223955%28v=sql.80%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa223955%28v=sql.80%29.aspx</a></p>
<p>So when should i choose sql_variant over varchar ?what is the advantage of sql_variant ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ndpatil999</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-365217</link>
		<dc:creator><![CDATA[ndpatil999]]></dc:creator>
		<pubDate>Sat, 27 Oct 2012 05:15:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-365217</guid>
		<description><![CDATA[Nice one]]></description>
		<content:encoded><![CDATA[<p>Nice one</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ndpatil999</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-365215</link>
		<dc:creator><![CDATA[ndpatil999]]></dc:creator>
		<pubDate>Sat, 27 Oct 2012 05:15:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-365215</guid>
		<description><![CDATA[Nice one.....................]]></description>
		<content:encoded><![CDATA[<p>Nice one&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raushan Jha</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-365210</link>
		<dc:creator><![CDATA[Raushan Jha]]></dc:creator>
		<pubDate>Sat, 27 Oct 2012 05:06:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-365210</guid>
		<description><![CDATA[Hi PInal,

Given query I tried on &quot;Sql Server 2008 R2&quot; as well as &quot;Sql Server 2012&quot; it&#039;s working in both of them.
--------------------------------------------------------------------
DECLARE @ListofIDs TABLE(IDs VARCHAR(100));
INSERT INTO @ListofIDs
VALUES(&#039;a&#039;),(&#039;10&#039;),(&#039;20&#039;),(&#039;c&#039;),(&#039;30&#039;),(&#039;d&#039;);
SELECT IDs FROM @ListofIDs;
--------------------------------------------------------------------

In &quot;Sql Server 2005&quot; it&#039;ll not work.]]></description>
		<content:encoded><![CDATA[<p>Hi PInal,</p>
<p>Given query I tried on &#8220;Sql Server 2008 R2&#8243; as well as &#8220;Sql Server 2012&#8243; it&#8217;s working in both of them.<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 />
DECLARE @ListofIDs TABLE(IDs VARCHAR(100));<br />
INSERT INTO @ListofIDs<br />
VALUES(&#8216;a&#8217;),(&#8217;10&#8242;),(&#8217;20&#8242;),(&#8216;c&#8217;),(&#8217;30&#8242;),(&#8216;d&#8217;);<br />
SELECT IDs FROM @ListofIDs;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>In &#8220;Sql Server 2005&#8243; it&#8217;ll not work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sandeep Mittal</title>
		<link>http://blog.sqlauthority.com/2012/10/27/sql-server-storing-variable-values-in-temporary-array-or-temporary-list/#comment-365188</link>
		<dc:creator><![CDATA[Sandeep Mittal]]></dc:creator>
		<pubDate>Sat, 27 Oct 2012 04:28:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=21319#comment-365188</guid>
		<description><![CDATA[Dear Pinal

The above script will even work in SQL Server 2008 also as both table variable and grouping sets are available in SQL Server 2008 onwards]]></description>
		<content:encoded><![CDATA[<p>Dear Pinal</p>
<p>The above script will even work in SQL Server 2008 also as both table variable and grouping sets are available in SQL Server 2008 onwards</p>
]]></content:encoded>
	</item>
</channel>
</rss>
