<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Real World SQL</title>
	<atom:link href="http://realworldsql.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://realworldsql.com</link>
	<description>SQL Solutions for the database developer</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:37:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Row Count data flow transformations</title>
		<link>http://realworldsql.com/2012/01/19/using-row-count-data-flow-transformations/</link>
		<comments>http://realworldsql.com/2012/01/19/using-row-count-data-flow-transformations/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 15:13:38 +0000</pubDate>
		<dc:creator>Jeff Rix</dc:creator>
				<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://realworldsql.com/?p=112</guid>
		<description><![CDATA[Create an Int32 user variable with a package scope. Configure the Row Count property Custom Properties&#62;Variable Name to the user variable. You cannot use the Row Count variable in the same dataflow it is set because it is processing the records and sending them to the destination at the same time. to use in the [...]]]></description>
			<content:encoded><![CDATA[<p>Create an Int32 user variable with a package scope. Configure the Row Count property Custom Properties&gt;Variable Name to the user variable.</p>
<p><a href="http://realworldsql.com/wp-content/uploads/2012/01/image5.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://realworldsql.com/wp-content/uploads/2012/01/image_thumb5.png" alt="image" width="458" height="356" border="0" /></a></p>
<p>You cannot use the Row Count variable in the same dataflow it is set because it is processing the records and sending them to the destination at the same time.</p>
<p>to use in the variable in an Execute SQL Task use an ADO.Net Connection Type and map the variable to an input parameter with the same data type using a parameter name that starts with the @ character.</p>
<p><a href="http://realworldsql.com/wp-content/uploads/2012/01/image6.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://realworldsql.com/wp-content/uploads/2012/01/image_thumb6.png" alt="image" width="476" height="145" border="0" /></a></p>
<p>In your query reference the variable using the parameter name and you will be all set!</p>
]]></content:encoded>
			<wfw:commentRss>http://realworldsql.com/2012/01/19/using-row-count-data-flow-transformations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Duplicate Keys in a dimensional hierarchy</title>
		<link>http://realworldsql.com/2012/01/13/duplicate-keys-in-a-dimensional-hierarchy/</link>
		<comments>http://realworldsql.com/2012/01/13/duplicate-keys-in-a-dimensional-hierarchy/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 21:41:40 +0000</pubDate>
		<dc:creator>Jeff Rix</dc:creator>
				<category><![CDATA[SSAS]]></category>
		<category><![CDATA[Dublicate Keys in a dimensional hierachy]]></category>
		<category><![CDATA[SSAS Duplicate Keys in a dimensional hierachy]]></category>

		<guid isPermaLink="false">http://realworldsql.com/?p=104</guid>
		<description><![CDATA[This  date hierarchy has year at the highest level and date at the lowest level. Months and quarters are between the highest and lowest levels in this data hierarchy. Each year has a fourth quarter and each Quarter has the month of December. The default property for dimensions in SSAS are set up to treat [...]]]></description>
			<content:encoded><![CDATA[<p>This  date hierarchy has year at the highest level and date at the lowest level. Months and quarters are between the highest and lowest levels in this data hierarchy.</p>
<p><a href="http://realworldsql.com/wp-content/uploads/2012/01/image2.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://realworldsql.com/wp-content/uploads/2012/01/image_thumb2.png" alt="image" width="496" height="256" border="0" /></a></p>
<p>Each year has a fourth quarter and each Quarter has the month of December.</p>
<p>The default property for dimensions in SSAS are set up to treat this as an error.</p>
<p>For most dimensions this would align with the business rules. If you had a football</p>
<p>league roster you would want the dimension to throw an error if it had a player</p>
<p>playing on more than 1 team.</p>
<p><a href="http://realworldsql.com/wp-content/uploads/2012/01/image3.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://realworldsql.com/wp-content/uploads/2012/01/image_thumb3.png" alt="image" width="421" height="226" border="0" /></a></p>
<p>Change the Key Duplicate Error Configuration to Ignore Error.</p>
<p><a href="http://realworldsql.com/wp-content/uploads/2012/01/image4.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://realworldsql.com/wp-content/uploads/2012/01/image_thumb4.png" alt="image" width="425" height="243" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://realworldsql.com/2012/01/13/duplicate-keys-in-a-dimensional-hierarchy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MDX Where clause</title>
		<link>http://realworldsql.com/2012/01/13/mdx-where-clause/</link>
		<comments>http://realworldsql.com/2012/01/13/mdx-where-clause/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 21:21:53 +0000</pubDate>
		<dc:creator>Jeff Rix</dc:creator>
				<category><![CDATA[MDX]]></category>
		<category><![CDATA[MDX where clause]]></category>

		<guid isPermaLink="false">http://realworldsql.com/?p=95</guid>
		<description><![CDATA[This MDX query shows delinquent balance and original principal balance across the servicing plan members with a rate type id equal to 1. SELECT {[measures].[Delinquent Balance], [measures].[Original Principal Balance]} ON COLUMNS ,NON EMPTY [Servicing Plan WID].[Servicing Plan ID].MEMBERS ON ROWS FROM [Cube T] WHERE {([Dim Rate Type].[Rate Type ID].&#38;[1])};]]></description>
			<content:encoded><![CDATA[<p>This MDX query shows delinquent balance and original principal balance across the servicing plan members with a rate type id equal to 1.</p>
<pre class="code"><span style="color: blue;">SELECT </span>{[measures].[Delinquent Balance], [measures].[Original Principal Balance]} <span style="color: blue;">ON COLUMNS </span>,<span style="color: blue;">NON EMPTY </span>[Servicing Plan WID].[Servicing Plan ID].<span style="color: blue;">MEMBERS ON ROWS FROM </span>[Cube T]
<span style="color: blue;">WHERE </span>{([Dim Rate Type].[Rate Type ID].&amp;[1])};</pre>
<p><a href="http://realworldsql.com/wp-content/uploads/2012/01/image1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://realworldsql.com/wp-content/uploads/2012/01/image_thumb1.png" alt="image" width="494" height="173" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://realworldsql.com/2012/01/13/mdx-where-clause/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update using joins- Query returning multiple values</title>
		<link>http://realworldsql.com/2012/01/13/update-using-joins-query-returning-multiple-values/</link>
		<comments>http://realworldsql.com/2012/01/13/update-using-joins-query-returning-multiple-values/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 15:33:23 +0000</pubDate>
		<dc:creator>Jeff Rix</dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[sql subquery returning more than 1 value]]></category>
		<category><![CDATA[sql update using joins]]></category>
		<category><![CDATA[subquery returning more than 1 value]]></category>
		<category><![CDATA[t-sql subquery returning more than 1 value]]></category>
		<category><![CDATA[t-sql update using joins]]></category>
		<category><![CDATA[update using joins]]></category>

		<guid isPermaLink="false">http://realworldsql.com/?p=88</guid>
		<description><![CDATA[If you are updating a tables column by selecting a column from another table there are different syntax you may use. If the select statement’s column contains more than 1 value for the specified join condition some syntax’s will update the value multiple times while another will fail the update statement. In this example Dennis [...]]]></description>
			<content:encoded><![CDATA[<p>If you are updating a tables column by selecting a column from another table there are different syntax you may use. If the select statement’s column contains more than 1 value for the specified join condition some syntax’s will update the value multiple times while another will fail the update statement.</p>
<p>In this example Dennis Rodman has multiple jersey player numbers in the UpdatePlayerData table.</p>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=create&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">create</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=table&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">table</a> PlayerData</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">(</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">Player_ID <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=int&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">int</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=identity&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">identity</a>(1,1) <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=primary&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">primary</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=key&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">key</a>,</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">Player_Name <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=varchar&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">varchar</a>(50) <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=not&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">not</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=null&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">null</a>,</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">Player_Number <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=int&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">int</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=not&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">not</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=null&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">null</a></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">)</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> PlayerData <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">('<span style="color: #8b0000;">Michael Jordan</span>', 23),('<span style="color: #8b0000;">Scottie Pippen</span>', 33),('<span style="color: #8b0000;">Dennis Rodman</span>', 91)</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=create&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">create</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=table&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">table</a> UpdatePlayerData</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">(</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">Player_ID <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=int&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">int</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=not&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">not</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=null&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">null</a>,</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">Player_Number <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=int&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">int</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=not&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">not</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=null&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">null</a></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">)</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=insert&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">insert</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=into&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">into</a> UpdatePlayerData <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=values&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">values</a></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">(3, 10),(1, 45),(3,73)</pre>
<p>The first two statements execute successfully and use the same execution plan. They update Dennis Rodman’s jersey to 10 and then to 73.</p>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><span style="color: #008000;">--Update 1</span></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=update&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">update</a> PlayerData</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=set&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">set</a> Player_Number = x.Player_Number</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=from&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">from</a></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">(</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=select&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">select</a> Player_ID, Player_Number <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=from&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">from</a> UpdatePlayerData</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">) <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=as&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">as</a> x</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=where&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">where</a> x.Player_ID = PlayerData.Player_ID</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><span style="color: #008000;">--Update 2 </span></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=update&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">update</a> a</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=set&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">set</a> a.Player_Number = b.Player_Number</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=from&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">from</a> PlayerData <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=as&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">as</a> a <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=join&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">join</a></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">UpdatePlayerData <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=as&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">as</a> b <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=on&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">on</a> a.Player_ID = b.Player_ID</pre>
<pre>The last value for his jersey is what is now displayed in the table.</pre>
<pre><a href="http://realworldsql.com/wp-content/uploads/2012/01/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://realworldsql.com/wp-content/uploads/2012/01/image_thumb.png" alt="image" width="516" height="145" border="0" /></a></pre>
<pre>This update syntax will fail the query stating that the sub-query returned more than 1 value.</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><span style="color: #008000;">--Update 3 that will fail </span></pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=update&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">update</a> PlayerData</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=set&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">set</a> Player_Number = (<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=select&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">select</a> upd.Player_Number <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=from&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">from</a> UpdatePlayerData <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=as&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">as</a> upd</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">					<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=where&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">where</a> upd.Player_ID = PlayerData.Player_ID)</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=where&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">where</a> Player_ID <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=in&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">in</a> (<a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=select&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">select</a> <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=distinct&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">distinct</a> Player_ID <a style="color: #0000ff;" href="http://search.microsoft.com/default.asp?so=RECCNT&amp;siteid=us%2Fdev&amp;p=1&amp;nq=NEW&amp;qu=from&amp;IntlSearch=&amp;boolean=PHRASE&amp;ig=01&amp;i=09&amp;i=99">from</a> UpdatePlayerData)</pre>
<p>Even though it fails in this example I would generally advice using this syntax so you can control the logic that decides which value it will set the column to as opposed to just setting it to the last value it processes.</p>
]]></content:encoded>
			<wfw:commentRss>http://realworldsql.com/2012/01/13/update-using-joins-query-returning-multiple-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

