<?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/"
	
	>
<channel>
	<title>
	Comments on: Not-so-dirty SQL hacks	</title>
	<atom:link href="https://lobsterpot.com.au/blog/2013/09/10/not-so-dirty-sql-hacks/feed/" rel="self" type="application/rss+xml" />
	<link>https://lobsterpot.com.au/blog/2013/09/10/not-so-dirty-sql-hacks/</link>
	<description></description>
	<lastBuildDate>Wed, 18 Sep 2013 02:49:20 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>
		By: merrillaldrich		</title>
		<link>https://lobsterpot.com.au/blog/2013/09/10/not-so-dirty-sql-hacks/#comment-2386</link>

		<dc:creator><![CDATA[merrillaldrich]]></dc:creator>
		<pubDate>Wed, 18 Sep 2013 02:49:20 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.lobsterpot.com.au/?p=3280#comment-2386</guid>

					<description><![CDATA[Rob - I don&#039;t have to code much. We buy everything. If I had to code this I would probably cringe and write it as you show here. It&#039;s become sort of a best practice, but it&#039;s still not pretty :-).]]></description>
			<content:encoded><![CDATA[<p>Rob &#8211; I don&#8217;t have to code much. We buy everything. If I had to code this I would probably cringe and write it as you show here. It&#8217;s become sort of a best practice, but it&#8217;s still not pretty :-).</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Allan S. Hansen		</title>
		<link>https://lobsterpot.com.au/blog/2013/09/10/not-so-dirty-sql-hacks/#comment-2385</link>

		<dc:creator><![CDATA[Allan S. Hansen]]></dc:creator>
		<pubDate>Tue, 17 Sep 2013 08:52:14 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.lobsterpot.com.au/?p=3280#comment-2385</guid>

					<description><![CDATA[I&#039;ve used XML for string concat in SQL Server for a couple of years now, and it&#039;s always felt &#039;hacky&#039; - but - yes, it really does the trick. 
I rarely - however - put it into production code other than data migration or imports which aren&#039;t that time sensitive.
In other situations, I&#039;d properly rather handle it with a combination of database/code logic as string concatenation often is connection to a business logic problem needing to be solved, more than an actual data problem.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve used XML for string concat in SQL Server for a couple of years now, and it&#8217;s always felt &#8216;hacky&#8217; &#8211; but &#8211; yes, it really does the trick.<br />
I rarely &#8211; however &#8211; put it into production code other than data migration or imports which aren&#8217;t that time sensitive.<br />
In other situations, I&#8217;d properly rather handle it with a combination of database/code logic as string concatenation often is connection to a business logic problem needing to be solved, more than an actual data problem.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Josías Hernández		</title>
		<link>https://lobsterpot.com.au/blog/2013/09/10/not-so-dirty-sql-hacks/#comment-2384</link>

		<dc:creator><![CDATA[Josías Hernández]]></dc:creator>
		<pubDate>Mon, 16 Sep 2013 18:32:26 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.lobsterpot.com.au/?p=3280#comment-2384</guid>

					<description><![CDATA[It is just AWESOME !!! I really enjoy it !!! Very smart the solution!!!
Thanks for the trick Rob.]]></description>
			<content:encoded><![CDATA[<p>It is just AWESOME !!! I really enjoy it !!! Very smart the solution!!!<br />
Thanks for the trick Rob.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Rob Farley		</title>
		<link>https://lobsterpot.com.au/blog/2013/09/10/not-so-dirty-sql-hacks/#comment-2383</link>

		<dc:creator><![CDATA[Rob Farley]]></dc:creator>
		<pubDate>Thu, 12 Sep 2013 23:50:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.lobsterpot.com.au/?p=3280#comment-2383</guid>

					<description><![CDATA[How do you handle it then, Merrill?]]></description>
			<content:encoded><![CDATA[<p>How do you handle it then, Merrill?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: merrillaldrich		</title>
		<link>https://lobsterpot.com.au/blog/2013/09/10/not-so-dirty-sql-hacks/#comment-2382</link>

		<dc:creator><![CDATA[merrillaldrich]]></dc:creator>
		<pubDate>Thu, 12 Sep 2013 19:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.lobsterpot.com.au/?p=3280#comment-2382</guid>

					<description><![CDATA[I&#039;m crazy and self-destructive, I guess. I know the performance advantages. I get the reasoning.
AND ... still I cringe when I see this XML concatenation trick. It&#039;s my childish idealism.
Still, great explanation of how to do it :-).]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m crazy and self-destructive, I guess. I know the performance advantages. I get the reasoning.<br />
AND &#8230; still I cringe when I see this XML concatenation trick. It&#8217;s my childish idealism.<br />
Still, great explanation of how to do it :-).</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Rob Farley		</title>
		<link>https://lobsterpot.com.au/blog/2013/09/10/not-so-dirty-sql-hacks/#comment-2381</link>

		<dc:creator><![CDATA[Rob Farley]]></dc:creator>
		<pubDate>Thu, 12 Sep 2013 16:25:26 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.lobsterpot.com.au/?p=3280#comment-2381</guid>

					<description><![CDATA[Based on the fact that it&#039;s not supported.
Based on the fact that it can be affected by non-clustered indexes, parallelism, and other good things, giving &#039;incorrect&#039; results.
Based on the fact that it&#039;s procedural and has no opportunity to be handled by the QO in a better way.
Based on the fact that you can&#039;t order the data how you like without risking the results.
If you must use code that moves through a result set in order like that, you should use a cursor. And that&#039;s saying something!!]]></description>
			<content:encoded><![CDATA[<p>Based on the fact that it&#8217;s not supported.<br />
Based on the fact that it can be affected by non-clustered indexes, parallelism, and other good things, giving &#8216;incorrect&#8217; results.<br />
Based on the fact that it&#8217;s procedural and has no opportunity to be handled by the QO in a better way.<br />
Based on the fact that you can&#8217;t order the data how you like without risking the results.<br />
If you must use code that moves through a result set in order like that, you should use a cursor. And that&#8217;s saying something!!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: JDS		</title>
		<link>https://lobsterpot.com.au/blog/2013/09/10/not-so-dirty-sql-hacks/#comment-2380</link>

		<dc:creator><![CDATA[JDS]]></dc:creator>
		<pubDate>Thu, 12 Sep 2013 16:13:40 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.lobsterpot.com.au/?p=3280#comment-2380</guid>

					<description><![CDATA[I have always done something like this below for quick string concatenation. Do you prefer the XML based approach upon performance or some other criteria?
IF EXISTS ( SELECT &#160;*
 &#160; &#160; &#160; &#160; &#160; &#160;FROM &#160; &#160;tempdb.dbo.sysobjects
 &#160; &#160; &#160; &#160; &#160; &#160;WHERE &#160; ID = OBJECT_ID(N&#039;tempdb..#source&#039;) ) 
BEGIN
 &#160; &#160;DROP TABLE #source
END
CREATE TABLE #source (
col1 CHAR(1)
)
INSERT INTO #source
 &#160; &#160; &#160; &#160;(col1)
 &#160;VALUES &#160;(&#039;a&#039;)
, (&#039;b&#039;)
, (&#039;c&#039;)
, (&#039;d&#039;)
, (&#039;e&#039;)
, (&#039;f&#039;)
, (&#039;g&#039;)
/*******************
String Concatenation
********************/
DECLARE @string VARCHAR(MAX)
SELECT @string = ISNULL(@string,&#039;&#039;) + &#039;,&#039; + col1
FROM #source s
SELECT @string]]></description>
			<content:encoded><![CDATA[<p>I have always done something like this below for quick string concatenation. Do you prefer the XML based approach upon performance or some other criteria?<br />
IF EXISTS ( SELECT &nbsp;*<br />
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FROM &nbsp; &nbsp;tempdb.dbo.sysobjects<br />
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WHERE &nbsp; ID = OBJECT_ID(N&#8217;tempdb..#source&#8217;) )<br />
BEGIN<br />
 &nbsp; &nbsp;DROP TABLE #source<br />
END<br />
CREATE TABLE #source (<br />
col1 CHAR(1)<br />
)<br />
INSERT INTO #source<br />
 &nbsp; &nbsp; &nbsp; &nbsp;(col1)<br />
 &nbsp;VALUES &nbsp;(&#8216;a&#8217;)<br />
, (&#8216;b&#8217;)<br />
, (&#8216;c&#8217;)<br />
, (&#8216;d&#8217;)<br />
, (&#8216;e&#8217;)<br />
, (&#8216;f&#8217;)<br />
, (&#8216;g&#8217;)<br />
/*******************<br />
String Concatenation<br />
********************/<br />
DECLARE @string VARCHAR(MAX)<br />
SELECT @string = ISNULL(@string,&#8221;) + &#8216;,&#8217; + col1<br />
FROM #source s<br />
SELECT @string</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
