 




<?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: SQL code made simpler</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/sql-code-made-simpler/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-code-made-simpler/</link>
	<description></description>
	<lastBuildDate>Tue, 21 May 2013 00:48:46 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: The Most-Watched IT Questions: July 5, 2011 - ITKE Community Blog</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-code-made-simpler/#comment-93932</link>
		<dc:creator>The Most-Watched IT Questions: July 5, 2011 - ITKE Community Blog</dc:creator>
		<pubDate>Tue, 05 Jul 2011 14:59:40 +0000</pubDate>
		<guid isPermaLink="false">#comment-93932</guid>
		<description><![CDATA[[...] 3. Carlosdl and TomLiotta help out a fellow member: SQL code made simpler. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 3. Carlosdl and TomLiotta help out a fellow member: SQL code made simpler. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Most-Watched IT Questions: June 28, 2011 - ITKE Community Blog</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-code-made-simpler/#comment-93703</link>
		<dc:creator>The Most-Watched IT Questions: June 28, 2011 - ITKE Community Blog</dc:creator>
		<pubDate>Tue, 28 Jun 2011 07:00:53 +0000</pubDate>
		<guid isPermaLink="false">#comment-93703</guid>
		<description><![CDATA[[...] 5. Carlosdl and TomLiotta try to help making some SQL code simpler. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 5. Carlosdl and TomLiotta try to help making some SQL code simpler. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-code-made-simpler/#comment-93619</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Fri, 24 Jun 2011 01:33:56 +0000</pubDate>
		<guid isPermaLink="false">#comment-93619</guid>
		<description><![CDATA[&lt;i&gt;I want to update the same column (tSTAdm) in File_A when it is not equal to the same column (tStAdm) in File_BU.&lt;/i&gt;

Because of &quot;&lt;i&gt;a unique key – TsStat&lt;/i&gt;&quot;, I assume you mean that you simply want File_a and File_BU to have matching tStADM values, based on matches for TsStat.

But you don&#039;t want to UPDATE all rows because many rows already have correct (i.e., matching) values.

I&#039;d say Carlosdl has the right answer. And if performance is the main reason to avoid just doing a straight UPDATE, then it&#039;s probably the best answer.

Tom]]></description>
		<content:encoded><![CDATA[<p><i>I want to update the same column (tSTAdm) in File_A when it is not equal to the same column (tStAdm) in File_BU.</i></p>
<p>Because of &#8220;<i>a unique key – TsStat</i>&#8220;, I assume you mean that you simply want File_a and File_BU to have matching tStADM values, based on matches for TsStat.</p>
<p>But you don&#8217;t want to UPDATE all rows because many rows already have correct (i.e., matching) values.</p>
<p>I&#8217;d say Carlosdl has the right answer. And if performance is the main reason to avoid just doing a straight UPDATE, then it&#8217;s probably the best answer.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-code-made-simpler/#comment-93612</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Thu, 23 Jun 2011 20:43:36 +0000</pubDate>
		<guid isPermaLink="false">#comment-93612</guid>
		<description><![CDATA[This is not simpler, but it could be faster in some circumstances:

&lt;pre&gt;UPDATE File_a as T01 SET T01.tStADM = 
	(Select tStAdm from File_BU WHERE T01.TsStat = TsStat)             
WHERE EXISTS (SELECT 1 
		FROM File_BU 
		WHERE TsStat = T01.TsStat
		AND tStADM &lt;&gt; T01.tStADM)&lt;/pre&gt;

I can&#039;t think of a simpler way to do it.  SQL server allows the use of JOINs in UPDATEs, and I think DB2 on some platforms has a MERGE statement that could probably simplify this task, but those commands are not part of the SQL standard.]]></description>
		<content:encoded><![CDATA[<p>This is not simpler, but it could be faster in some circumstances:</p>
<pre>UPDATE File_a as T01 SET T01.tStADM = 
	(Select tStAdm from File_BU WHERE T01.TsStat = TsStat)             
WHERE EXISTS (SELECT 1 
		FROM File_BU 
		WHERE TsStat = T01.TsStat
		AND tStADM &lt;&gt; T01.tStADM)</pre>
<p>I can&#8217;t think of a simpler way to do it.  SQL server allows the use of JOINs in UPDATEs, and I think DB2 on some platforms has a MERGE statement that could probably simplify this task, but those commands are not part of the SQL standard.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/9 queries in 0.013 seconds using memcached
Object Caching 310/313 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-21 02:37:23 -->