<?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>Microsoft Business Intelligence - David Stewart</title>
	<atom:link href="http://www.dstewart.com.au/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dstewart.com.au</link>
	<description>A blog about designing and developing Business Intelligence solutions using Microsoft SQL Server</description>
	<lastBuildDate>Sat, 25 Aug 2012 08:13:31 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.7.1</generator>
	<item>
		<title>Free Text Dimension Attributes in SSAS</title>
		<link>http://www.dstewart.com.au/2012/08/free-text-dimension-attributes-in-ssas/</link>
		<comments>http://www.dstewart.com.au/2012/08/free-text-dimension-attributes-in-ssas/#comments</comments>
		<pubDate>Sat, 25 Aug 2012 08:13:31 +0000</pubDate>
		<dc:creator><![CDATA[David Stewart]]></dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[SSAS]]></category>
		<category><![CDATA[SSAS Collation]]></category>

		<guid isPermaLink="false">http://110.232.142.10/~dstewart/?p=109</guid>
		<description><![CDATA[In some cases we need to bring comments or descriptions into a dimension in SSAS for detail reporting. For example the comment from a maintenance worker against a machine breakdown, or a geological survey description. These fields are typically free text in the source system and as such don&#8217;t contain restrictions or constraints on data &#8230; <a href="http://www.dstewart.com.au/2012/08/free-text-dimension-attributes-in-ssas/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>In some cases we need to bring comments or descriptions into a dimension in SSAS for detail reporting. For example the comment from a maintenance worker against a machine breakdown, or a geological survey description. These fields are typically free text in the source system and as such don&#8217;t contain restrictions or constraints on data entry (e.g. upper and lower case, empty values, white-space, uniqueness). When you try and process these attributes you&#8217;ll run into a couple of issues.</p>
<p>To demonstrate this I&#8217;ve knocked up a few rows with variations in case of the same text, a null value and an empty string.</p>
<p><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2012/08/free-text.png" rel="lightbox[109]" title="Free Text Sample Data"><img class="aligncenter size-full wp-image-111" title="Free Text Sample Data" src="http://110.232.142.10/~dstewart/wp-content/uploads/2012/08/free-text.png" alt="Free Text Sample Data" width="177" height="173" /></a></p>
<p>Creating a dimension based on this table in SSAS gives the following error when we try to process it &#8211; &#8220;Errors in the OLAP storage engine: A duplicate attribute key has been found when processing: Table: &#8216;dbo_FreeText&#8217;, Column: &#8216;Comment&#8217;, Value: &#8221;. The attribute is &#8216;Comment&#8217;&#8221;.</p>
<p><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2012/08/ssas-error-empty.png" rel="lightbox[109]" title="SSAS Duplicate Key - Empty and NULL Values"><img class="aligncenter size-full wp-image-110" title="SSAS Duplicate Key - Empty and NULL Values" src="http://110.232.142.10/~dstewart/wp-content/uploads/2012/08/ssas-error-empty.png" alt="SSAS Duplicate Key - Empty and NULL Values" width="842" height="600" /></a></p>
<p>This is due to the NullProcessing property on the dimension attribute, for which the default setting is Automatic. This specifies that the Null value is converted to zero (for numeric data items) or in this case a blank string (for string data items). This means that we&#8217;ve now got a null value which is converted to an empty string and an empty string, resulting in duplicate key values. If we set NullProcessing to Preserve this will fix this, giving us two distinct key values. If your database or this particular field is case sensitive you&#8217;ll then likely run into a second issue with a very similar error message &#8211; &#8220;Errors in the OLAP storage engine: A duplicate attribute key has been found when processing: Table: &#8216;dbo_FreeText&#8217;, Column: &#8216;Comment&#8217;, Value: &#8216;Some comment&#8217;. The attribute is &#8216;Comment&#8217;&#8221;. This comes down to a difference in case sensitivity between the underlying database and Analysis Services, which by default is case insensitive. In SSAS this is set at the attribute level. If you select the Comment attribute and expand they KeyColumns group you&#8217;ll find the collation property, under which you&#8217;ll find a case sensitive check box.</p>
<p><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2012/08/attribute-collation.png" rel="lightbox[109]" title="SSAS Attribute Collation"><img class="aligncenter size-full wp-image-112" title="SSAS Attribute Collation" src="http://110.232.142.10/~dstewart/wp-content/uploads/2012/08/attribute-collation.png" alt="SSAS Attribute Collation" width="412" height="326" /></a></p>
<p>Once you&#8217;ve checked this the dimension should now process successfully. When we browse the comment attribute you&#8217;ll notice two &#8220;blank&#8221; values (null and empty) and multiple values for &#8220;some comment&#8221;. This example assumes that these are different discrete values. If this isn&#8217;t the case this should be handled in ETL i.e. converting null values to empty strings and standardising on case.</p>
<p><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2012/08/comment-ssas-browser.png" rel="lightbox[109]" title="SSAS Browser Comment Attribute"><img class="aligncenter size-full wp-image-113" title="SSAS Browser Comment Attribute" src="http://110.232.142.10/~dstewart/wp-content/uploads/2012/08/comment-ssas-browser.png" alt="SSAS Browser Comment Attribute" width="538" height="264" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dstewart.com.au/2012/08/free-text-dimension-attributes-in-ssas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Transact-SQL IN</title>
		<link>http://www.dstewart.com.au/2012/08/ransact-sql-in/</link>
		<comments>http://www.dstewart.com.au/2012/08/ransact-sql-in/#comments</comments>
		<pubDate>Mon, 20 Aug 2012 15:14:36 +0000</pubDate>
		<dc:creator><![CDATA[David Stewart]]></dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[T-SQL Basics]]></category>
		<category><![CDATA[T-SQL Operators]]></category>

		<guid isPermaLink="false">http://110.232.142.10/~dstewart/?p=101</guid>
		<description><![CDATA[The T-SQL IN operator can be used to test whether a given value matches any item in a particular list or sub-query. If the given value equals an item in the list or sub-query the expression returns true, otherwise it returns false. The following example (based on AdventureWorks) uses IN to return all the departments &#8230; <a href="http://www.dstewart.com.au/2012/08/ransact-sql-in/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The T-SQL IN operator can be used to test whether a given value matches any item in a particular list or sub-query. If the given value equals an item in the list or sub-query the expression returns true, otherwise it returns false.</p>
<p>The following example (based on AdventureWorks) uses IN to return all the departments which are in the research and development, or quality assurance groups. Below is the full list of departments:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DepartmentID Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GroupName &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ModifiedDate<br />
------------ -------------------------------------------------- -------------------------------------------------- -----------------------<br />
1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Engineering &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Research and Development &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Tool Design &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Research and Development &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sales &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sales and Marketing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Marketing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sales and Marketing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Purchasing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inventory Management &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Research and Development &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Research and Development &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Production &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Manufacturing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Production Control &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Manufacturing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Human Resources &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Finance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Information Services &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
12 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Document Control &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Quality Assurance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
13 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Quality Assurance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Quality Assurance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
14 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Facilities and Maintenance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
15 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Shipping and Receiving &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inventory Management &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
16 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Executive &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
<br />
(16 row(s) affected)</div></div>
<p>Now to get only the departments that are in the groups research and development or quality assurance. We need to use the IN operator in the WHERE clause to restrict the rows returned:</p>
<div class="codecolorer-container tsql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="tsql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000FF;">SELECT</span><br />
&nbsp; &nbsp;<span style="color: #808080;">*</span><br />
<span style="color: #0000FF;">FROM</span><br />
&nbsp; &nbsp;HumanResources.<span style="color: #202020;">Department</span><br />
<span style="color: #0000FF;">WHERE</span><br />
&nbsp; &nbsp;GroupName <span style="color: #808080;">IN</span> <span style="color: #808080;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">'Research and Development'</span><br />
&nbsp; &nbsp;,&nbsp; <span style="color: #FF0000;">'Quality Assurance'</span><br />
&nbsp; &nbsp;<span style="color: #808080;">&#41;</span></div></td></tr></tbody></table></div>
<p>This gives us the following result:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DepartmentID Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GroupName &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ModifiedDate<br />
------------ -------------------------------------------------- -------------------------------------------------- -----------------------<br />
1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Engineering &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Research and Development &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Tool Design &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Research and Development &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Research and Development &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Research and Development &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
12 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Document Control &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Quality Assurance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
13 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Quality Assurance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Quality Assurance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
<br />
(5 row(s) affected)</div></div>
<p>We can also include NOT with the IN operator, which logically returns false when the value matches an item in the list and true otherwise. So we could get all departments that aren&#8217;t in the above groups:</p>
<div class="codecolorer-container tsql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="tsql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000FF;">SELECT</span><br />
&nbsp; &nbsp;<span style="color: #808080;">*</span><br />
<span style="color: #0000FF;">FROM</span><br />
&nbsp; &nbsp;HumanResources.<span style="color: #202020;">Department</span><br />
<span style="color: #0000FF;">WHERE</span><br />
&nbsp; &nbsp;GroupName <span style="color: #808080;">NOT</span> <span style="color: #808080;">IN</span> <span style="color: #808080;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">'Research and Development'</span><br />
&nbsp; &nbsp;,&nbsp; <span style="color: #FF0000;">'Quality Assurance'</span><br />
&nbsp; &nbsp;<span style="color: #808080;">&#41;</span></div></td></tr></tbody></table></div>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DepartmentID Name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GroupName &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ModifiedDate<br />
------------ -------------------------------------------------- -------------------------------------------------- -----------------------<br />
3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sales &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sales and Marketing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Marketing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Sales and Marketing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Purchasing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inventory Management &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
7 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Production &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Manufacturing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Production Control &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Manufacturing &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1998-06-01 00:00:00.000<br />
9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Human Resources &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
10 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Finance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Information Services &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
14 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Facilities and Maintenance &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
15 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Shipping and Receiving &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Inventory Management &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
16 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Executive &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Executive General and Administration &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1998-06-01 00:00:00.000<br />
<br />
(11 row(s) affected)</div></div>
<p>We can also use sub-queries with the IN operator. For example we might want to get a list of employee id&#8217;s that have been assigned to a department within the Quality Assurance group:</p>
<div class="codecolorer-container tsql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="tsql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000FF;">SELECT</span><br />
&nbsp; &nbsp;EmployeeID<br />
<span style="color: #0000FF;">FROM</span><br />
&nbsp; &nbsp;HumanResources.<span style="color: #202020;">EmployeeDepartmentHistory</span><br />
<span style="color: #0000FF;">WHERE</span><br />
&nbsp; &nbsp;DepartmentID <span style="color: #808080;">IN</span> <span style="color: #808080;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">SELECT</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DepartmentID<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">FROM</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HumanResources.<span style="color: #202020;">Department</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHERE</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GroupName <span style="color: #808080;">=</span> <span style="color: #FF0000;">'Quality Assurance'</span><br />
&nbsp; &nbsp;<span style="color: #808080;">&#41;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.dstewart.com.au/2012/08/ransact-sql-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML for Analysis parser: The LocaleIdentifier property is not overwritable and cannot be assigned a new value</title>
		<link>http://www.dstewart.com.au/2012/08/xml-for-analysis-parser-localeidentifier-property/</link>
		<comments>http://www.dstewart.com.au/2012/08/xml-for-analysis-parser-localeidentifier-property/#comments</comments>
		<pubDate>Fri, 10 Aug 2012 05:45:47 +0000</pubDate>
		<dc:creator><![CDATA[David Stewart]]></dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[SQL Server Analysis Services]]></category>
		<category><![CDATA[SSAS]]></category>

		<guid isPermaLink="false">http://110.232.142.10/~dstewart/?p=95</guid>
		<description><![CDATA[Previously I wrote a post about the LocaleIdentifier error when browsing an Analysis Services cube via Management Studio. Whilst it&#8217;s annoying, it really only affects developers so quickly slips down the list of priorities to address! However, when it starts to affect users it becomes a serious issue. Working on another project with an Excel &#8230; <a href="http://www.dstewart.com.au/2012/08/xml-for-analysis-parser-localeidentifier-property/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Previously I wrote a post about the <a title="LocaleIdentifier error when browsing SSAS cube via Management Studio" href="http://110.232.142.10/~dstewart/2011/10/localeidentifier-error-when-browsing-ssas-cube-via-management-studio/">LocaleIdentifier error</a> when browsing an Analysis Services cube via Management Studio. Whilst it&#8217;s annoying, it really only affects developers so quickly slips down the list of priorities to address! However, when it starts to affect users it becomes a serious issue. Working on another project with an Excel component this issue came up in a couple of places &#8211; connecting to the cube from Excel (sometimes), and using drill-through in Excel.</p>
<p>After looking into this for a while I came across a solution, although it&#8217;s not one I feel completely comfortable with.</p>
<p>1. Go to Windows &gt; Control Panel &gt; Region and Language</p>
<p>2. Update the Format to &#8220;English (United States)&#8221;</p>
<p><img class="size-full wp-image-96 alignnone" title="Region and Language Format" src="http://110.232.142.10/~dstewart/wp-content/uploads/2012/08/region-and-language-format.png" alt="Region and Language Format" width="477" height="550" /></p>
<p>3. Click Apply</p>
<p>4. Update the Format back to your original language, in my case &#8220;English (Australia)&#8221;</p>
<p>5. Click Apply</p>
<p>6. Click OK</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dstewart.com.au/2012/08/xml-for-analysis-parser-localeidentifier-property/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SSRS Tablix Group Row Numbers</title>
		<link>http://www.dstewart.com.au/2011/11/ssrs-tablix-group-row-numbers/</link>
		<comments>http://www.dstewart.com.au/2011/11/ssrs-tablix-group-row-numbers/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 11:31:42 +0000</pubDate>
		<dc:creator><![CDATA[David Stewart]]></dc:creator>
				<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[Reporting]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://110.232.142.10/~dstewart/?p=86</guid>
		<description><![CDATA[Every now and then I get the requirement to add row numbers to a table in SQL Server Reporting Services. Usually this is simple enough using the row number function - http://msdn.microsoft.com/en-us/library/ms159225(v=SQL.100).aspx. However, typically becomes a lot less straight forward when requirements are changed slightly! In this case I was developing a monthly report which returned &#8230; <a href="http://www.dstewart.com.au/2011/11/ssrs-tablix-group-row-numbers/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Every now and then I get the requirement to add row numbers to a table in SQL Server Reporting Services. Usually this is simple enough using the row number function - <a href="http://msdn.microsoft.com/en-us/library/ms159225(v=SQL.100).aspx">http://msdn.microsoft.com/en-us/library/ms159225(v=SQL.100).aspx</a>. However, typically becomes a lot less straight forward when requirements are changed slightly!</p>
<p>In this case I was developing a monthly report which returned summarised information by account code for input into a finance system and included several detail sections for auditing and reconciliation. The summary table required a sequence number, which reflected the row number of the table. I had no joy scoping the row number function to the table or group, so started thinking about alternative solutions. The report contained multiple sections using the same source query, so returning multiple queries was inefficient and created duplicate code. Given the tablix is grouped by account code, it&#8217;s effectively returning a distinct list of account codes. Therefore, the row/sequence number is actually the row number of the account code in a distinct list of the account codes. Once you start looking to utilise this, it&#8217;s actually fairly simple to get the desired row numbers.</p>
<p>For this example I created a simple table of sample data containing two columns &#8211; Account Code and Amount.</p>
<p><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2011/11/transfers_table.png" rel="lightbox[86]" title="Transfers Table Sample Data"><img class="aligncenter size-full wp-image-90" title="Transfers Table Sample Data" src="http://110.232.142.10/~dstewart/wp-content/uploads/2011/11/transfers_table.png" alt="" width="305" height="369" /></a>I then created a simple tablix grouped by account code &#8211; displaying the account code, amount, and a distinct count of the account code. Looking at the output below it&#8217;s pretty easy to recognise that the row number is a cumulative sum of the distinct count of account codes.</p>
<p><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2011/11/transfers_distinct_count.png" rel="lightbox[86]" title="Tablix Grouping Distinct Count"><img class="aligncenter size-full wp-image-91" title="Tablix Grouping Distinct Count" src="http://110.232.142.10/~dstewart/wp-content/uploads/2011/11/transfers_distinct_count.png" alt="" width="381" height="148" /></a>Conveniently there&#8217;s a function in SSRS to do just that! RunningValue - <a href="http://msdn.microsoft.com/en-us/library/ms159136.aspx">http://msdn.microsoft.com/en-us/library/ms159136.aspx</a>. Running value accepts three parameters&#8230;<br />
<strong><em>expression </em></strong>- the expression or field to aggregate,  in this case the account code field.<br />
<strong><em>function </em></strong>- the aggregate function to apply, in this case count distinct.<br />
<strong><em>scope </em></strong>- the name of the dataset, data region, etc&#8230; in this case the tablix.<br />
Having not renamed the tablix, I replaced the distinct count field with the following expression&#8230;</p>
<div class="codecolorer-container vbnet default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="vbnet codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000;">=</span>RunningValue<span style="color: #000000;">&#40;</span>Fields!AccountCode.<span style="color: #0000FF;">Value</span>, CountDistinct, <span style="color: #808080;">&quot;Tablix1&quot;</span><span style="color: #000000;">&#41;</span></div></td></tr></tbody></table></div>
<p>&#8230;and there we have it, row numbers in a tablix group.</p>
<p><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2011/11/transfers_row_num.png" rel="lightbox[86]" title="Tablix Group Row Numbers"><img class="aligncenter size-full wp-image-92" title="Tablix Group Row Numbers" src="http://110.232.142.10/~dstewart/wp-content/uploads/2011/11/transfers_row_num.png" alt="" width="382" height="151" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dstewart.com.au/2011/11/ssrs-tablix-group-row-numbers/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>SSAS Set Colour of Non-Calculated Measures</title>
		<link>http://www.dstewart.com.au/2011/10/ssas-set-colour-of-non-calculated-measures/</link>
		<comments>http://www.dstewart.com.au/2011/10/ssas-set-colour-of-non-calculated-measures/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 13:39:34 +0000</pubDate>
		<dc:creator><![CDATA[David Stewart]]></dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[MDX]]></category>
		<category><![CDATA[SQL Server Analysis Services]]></category>
		<category><![CDATA[SSAS]]></category>

		<guid isPermaLink="false">http://110.232.142.10/~dstewart/?p=69</guid>
		<description><![CDATA[Recently I had a requirement to set the colour of a couple of non-calculated measures in Analysis Services to differentiate between an actual and inferred value. It was another one of those things that I&#8217;d remembered being as simple as selecting a value from the properties screen&#8230; Unfortunately my memory deceives me and I was &#8230; <a href="http://www.dstewart.com.au/2011/10/ssas-set-colour-of-non-calculated-measures/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently I had a requirement to set the colour of a couple of non-calculated measures in Analysis Services to differentiate between an actual and inferred value. It was another one of those things that I&#8217;d remembered being as simple as selecting a value from the properties screen&#8230; Unfortunately my memory deceives me and I was greeted with a properties window totally devoid of any colour settings!</p>
<p>Conveniently it&#8217;s easy (enough) to set the colours using MDX in the cube calculation script. SSAS defines colour values using a somewhat strange system, there&#8217;s a great post from Boyan Penev explaining this &#8211; <a title="Colour Codes in SSAS" href="http://www.bp-msbi.com/2011/06/colour-codes-in-ssas/" target="_blank">Colour Codes in SSAS</a>.</p>
<p>To set the colour of the Amount measure in the Adventure Works cube to a lovely shade of pink, you&#8217;d add the following line to the cube calculation script&#8230;</p>
<div class="codecolorer-container tsql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="tsql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">F<span style="color: #808080;">OR</span>E_COL<span style="color: #808080;">OR</span> <span style="color: #808080;">&#40;</span> <span style="color: #808080;">&#91;</span>Measures<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>Amount<span style="color: #808080;">&#93;</span> <span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #000;">16711935</span>;</div></td></tr></tbody></table></div>
<p>With the resulting err&#8230; lovely pink measure when browsed from Management Studio.</p>
<p><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/pink-measure.png" rel="lightbox[69]" title="Pink Coloured Non-Calculated Measure"><img class="aligncenter size-full wp-image-75" title="Pink Coloured Non-Calculated Measure" src="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/pink-measure.png" alt="Pink Coloured Non-Calculated Measure" width="671" height="245" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dstewart.com.au/2011/10/ssas-set-colour-of-non-calculated-measures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>T-SQL: Get a List of Most Frequent Words in a String</title>
		<link>http://www.dstewart.com.au/2011/10/t-sql-get-a-list-of-most-frequent-words-in-a-string/</link>
		<comments>http://www.dstewart.com.au/2011/10/t-sql-get-a-list-of-most-frequent-words-in-a-string/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 15:51:46 +0000</pubDate>
		<dc:creator><![CDATA[David Stewart]]></dc:creator>
				<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[CTE]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://110.232.142.10/~dstewart/?p=43</guid>
		<description><![CDATA[I saw a thread on MSDN Forums recently asking for T-SQL to get a list of the top 10 most frequent words in a given string. While this could be done using cursors, I have a general dislike of them! It got me interested in whether or not this could be achieved using a common &#8230; <a href="http://www.dstewart.com.au/2011/10/t-sql-get-a-list-of-most-frequent-words-in-a-string/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I saw a thread on MSDN Forums recently asking for T-SQL to get a list of the top 10 most frequent words in a given string. While this could be done using cursors, I have a general dislike of them! It got me interested in whether or not this could be achieved using a common table expression&#8230;</p>
<p>So I had a think and put together some T-SQL, with some success (it didn&#8217;t have a syntax error or run forever). After a few changes I had broken the string up into a table of words, with a bit to indicate whether or not each record is a valid word. In this case, I just defined a word as a string of characters containing only a-z or A-Z, followed by any other character (or no character). This could easily be adjusted to include other characters though, for example &#8216; to allow we&#8217;re, haven&#8217;t, etc.</p>
<p>Essentially the logic behind the CTE is&#8230;</p>
<ol>
<li>You have two integers a and b &#8211; one indicating the start of the current word (a), the other the possible length of the word (b).</li>
<li>If the character at a isn&#8217;t an alphabetic character, then this isn&#8217;t the start of a word. So we need to move a to the next character.</li>
<li>If the character at a + b (one character after the end of the possible current word) isn&#8217;t an alphabetic character then we&#8217;ve found a word. So we should mark the string starting at a of length b as a word. In this case we set a = a + b + 1, and reset b = 1. If a + b is an alphabetic character, then we haven&#8217;t reached the end of the word yet and we need to increment b by 1.</li>
</ol>
<p>Below is the T-SQL I used, applied over this post.</p>
<div>
<div class="codecolorer-container tsql default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br /></div></td><td><div class="tsql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000FF;">DECLARE</span> @<span style="color: #0000FF;">Text</span> <span style="color: #FF00FF;">var</span> <span style="color: #0000FF;">char</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">max</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">''</span>; <span style="color: #008080;">-- remove space from var char</span><br />
<br />
<span style="color: #008080;">-- A - Z = 65 = 90</span><br />
<span style="color: #008080;">-- a - z = 97 = 122</span><br />
<br />
<span style="color: #0000FF;">WITH</span><br />
Chars <span style="color: #0000FF;">AS</span> <span style="color: #808080;">&#40;</span><br />
<br />
<span style="color: #0000FF;">SELECT</span><br />
&nbsp; &nbsp;<span style="color: #000;">1</span> <span style="color: #0000FF;">AS</span> a_in<br />
, &nbsp;<span style="color: #000;">1</span> <span style="color: #0000FF;">AS</span> b_in<br />
, &nbsp;<span style="color: #0000FF;">CASE</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, <span style="color: #000;">1</span>, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">65</span> <span style="color: #808080;">AND</span> <span style="color: #000;">90</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080;">AND</span> &nbsp; <span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, <span style="color: #000;">1</span>, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">97</span> <span style="color: #808080;">AND</span> <span style="color: #000;">122</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">THEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000;">2</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">ELSE</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000;">1</span><br />
&nbsp; &nbsp;<span style="color: #0000FF;">END</span> <span style="color: #0000FF;">AS</span> a<br />
, &nbsp;<span style="color: #000;">1</span> <span style="color: #0000FF;">AS</span> b<br />
, &nbsp;<span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, <span style="color: #000;">1</span>, <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> Word<br />
, &nbsp;<span style="color: #000;">0</span> <span style="color: #0000FF;">AS</span> IsWord<br />
<br />
<span style="color: #0000FF;">UNION</span> <span style="color: #808080;">ALL</span><br />
<br />
<span style="color: #0000FF;">SELECT</span><br />
&nbsp; &nbsp;a <span style="color: #0000FF;">AS</span> a_in<br />
, &nbsp;b <span style="color: #0000FF;">AS</span> b_in<br />
, &nbsp;<span style="color: #0000FF;">CASE</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">65</span> <span style="color: #808080;">AND</span> <span style="color: #000;">90</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080;">AND</span> &nbsp; <span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">97</span> <span style="color: #808080;">AND</span> <span style="color: #000;">122</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">THEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a <span style="color: #808080;">+</span> <span style="color: #000;">1</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a <span style="color: #808080;">+</span> b, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">65</span> <span style="color: #808080;">AND</span> <span style="color: #000;">90</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080;">OR</span> <span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a <span style="color: #808080;">+</span> b, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">97</span> <span style="color: #808080;">AND</span> <span style="color: #000;">122</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">THEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">ELSE</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a <span style="color: #808080;">+</span> <span style="color: #000;">1</span> <span style="color: #808080;">+</span> b<br />
&nbsp; &nbsp;<span style="color: #0000FF;">END</span> <span style="color: #0000FF;">AS</span> a<br />
, &nbsp;<span style="color: #0000FF;">CASE</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">65</span> <span style="color: #808080;">AND</span> <span style="color: #000;">90</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080;">AND</span> &nbsp; <span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">97</span> <span style="color: #808080;">AND</span> <span style="color: #000;">122</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">THEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;b<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a <span style="color: #808080;">+</span> b, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">65</span> <span style="color: #808080;">AND</span> <span style="color: #000;">90</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080;">OR</span> <span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a <span style="color: #808080;">+</span> b, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">97</span> <span style="color: #808080;">AND</span> <span style="color: #000;">122</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">THEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;b <span style="color: #808080;">+</span> <span style="color: #000;">1</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">ELSE</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000;">1</span><br />
&nbsp; &nbsp;<span style="color: #0000FF;">END</span> <span style="color: #0000FF;">AS</span> b<br />
, &nbsp;<span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a, b<span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> Word<br />
, &nbsp;<span style="color: #0000FF;">CASE</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">WHEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a <span style="color: #808080;">+</span> b, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">65</span> <span style="color: #808080;">AND</span> <span style="color: #000;">90</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080;">OR</span> <span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a <span style="color: #808080;">+</span> b, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">97</span> <span style="color: #808080;">AND</span> <span style="color: #000;">122</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #808080;">OR</span> <span style="color: #808080;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">65</span> <span style="color: #808080;">AND</span> <span style="color: #000;">90</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080;">AND</span>&nbsp; &nbsp;<span style="color: #FF00FF;">ASCII</span><span style="color: #808080;">&#40;</span><span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span>, a, <span style="color: #000;">1</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">NOT</span> <span style="color: #808080;">BETWEEN</span> <span style="color: #000;">97</span> <span style="color: #808080;">AND</span> <span style="color: #000;">122</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">THEN</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000;">0</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">ELSE</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000;">1</span><br />
&nbsp; &nbsp;<span style="color: #0000FF;">END</span> <span style="color: #0000FF;">AS</span> IsWord<br />
<span style="color: #0000FF;">FROM</span><br />
&nbsp; &nbsp;Chars<br />
<span style="color: #0000FF;">WHERE</span><br />
&nbsp; &nbsp;a <span style="color: #808080;">&lt;</span> <span style="color: #FF00FF;">LEN</span><span style="color: #808080;">&#40;</span>@<span style="color: #0000FF;">Text</span><span style="color: #808080;">&#41;</span><br />
<br />
<span style="color: #808080;">&#41;</span><br />
<br />
<span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">TOP</span> <span style="color: #000;">10</span><br />
&nbsp; &nbsp;Word<br />
, &nbsp;<span style="color: #FF00FF;">COUNT</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">*</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> NumberOfTimesUsed<br />
<span style="color: #0000FF;">FROM</span><br />
&nbsp; &nbsp;Chars<br />
<span style="color: #0000FF;">WHERE</span><br />
&nbsp; &nbsp;IsWord <span style="color: #808080;">=</span> <span style="color: #000;">1</span><br />
<span style="color: #0000FF;">GROUP</span> <span style="color: #0000FF;">BY</span><br />
&nbsp; &nbsp;Word<br />
<span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span><br />
&nbsp; &nbsp;<span style="color: #000;">2</span> <span style="color: #0000FF;">DESC</span><br />
<span style="color: #0000FF;">OPTION</span><br />
&nbsp; &nbsp;<span style="color: #808080;">&#40;</span>MAXRECURSION <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span></div></td></tr></tbody></table></div>
</div>
<div>&#8230;and a screen shot of the ten most frequently used words. Apparently I like short words&#8230;</div>
<div><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/word-count-output.png" rel="lightbox[43]" title="Top 10 Most Frequent Words"><img class="aligncenter size-full wp-image-44" title="Top 10 Most Frequent Words" src="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/word-count-output.png" alt="Top 10 Most Frequent Words" width="221" height="234" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.dstewart.com.au/2011/10/t-sql-get-a-list-of-most-frequent-words-in-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSIS Dimension Merge SCD v1.6 &#8211; Duplicate Rows Ouput</title>
		<link>http://www.dstewart.com.au/2011/10/ssis-dimension-merge-scd-v1-6-duplicate-rows-output/</link>
		<comments>http://www.dstewart.com.au/2011/10/ssis-dimension-merge-scd-v1-6-duplicate-rows-output/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 10:39:37 +0000</pubDate>
		<dc:creator><![CDATA[David Stewart]]></dc:creator>
				<category><![CDATA[Integration Services]]></category>
		<category><![CDATA[Data Warehousing]]></category>
		<category><![CDATA[Dimension Merge SCD]]></category>
		<category><![CDATA[ETL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://110.232.142.10/~dstewart/?p=22</guid>
		<description><![CDATA[Recently, a couple of people I&#8217;m working with came across a strange issue using the new version of the Dimension Merge SCD component. During the first load all rows would be output as new records (as you&#8217;d expect), but when running the same load again all rows would be output as both unchanged and new &#8230; <a href="http://www.dstewart.com.au/2011/10/ssis-dimension-merge-scd-v1-6-duplicate-rows-output/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently, a couple of people I&#8217;m working with came across a strange issue using the new version of the Dimension Merge SCD component. During the first load all rows would be output as new records (as you&#8217;d expect), but when running the same load again all rows would be output as both unchanged and new (not as you&#8217;d expect!). The behavior seemed very strange, only a couple of packages exhibited the issue.</p>
<p>Initially I had little joy trying to replicate the issues with Adventure Works, but found the source of the problem after chatting to <a title="Bhavik Merchant" href="http://twitter.com/#!/BhavikMerchant" target="_blank">Bhavik Merchant</a> about it. The problem arose due to two main reasons&#8230;</p>
<ol>
<li>Effective and expiry dates were being managed externally of the Dimension Merge SCD component.</li>
<li>The default for the last records expiry date in the Dimension Merge SCD is the SQL Server datetime maximum value, while the warehouse was using 2199-12-31.</li>
</ol>
<p>So, in the initial load the records where being inserted with an expiry date of 2199-12-31 which from the Dimension Merge SCD components point of view means the records aren&#8217;t current until the end of time. For the second load the Dimension Merge SCD would assign an expiry date of 9999-12-31 to the same source records, making them more recent than those inserted in the first load. So the second load would result in all the records being output again with the different active to date. Since the effective and expiry dates were then managed externally this resulted in two identical records being inserted into the destination table.</p>
<p>The &#8220;fix&#8221; was simple. Either change the default for the last records expiry date in the data warehouse to 9999-12-31, or set the last records expiry date in the Dimension Merge SCD to the same value being used in the data warehouse. The screenshot below shows where to change this value in the component.</p>
<p style="text-align: center;"><a title="Setting Dimension Merge SCD Effective/Expiry Settings" href="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/dim-merge-scd.png" rel="lightbox[dmscd]"><img class="size-large wp-image-31 aligncenter" title="Dimension Merge SCD Effective/Expiry Settings" src="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/dim-merge-scd-1024x519.png" alt="Dimension Merge SCD Effective/Expiry Settings" width="590" height="299" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dstewart.com.au/2011/10/ssis-dimension-merge-scd-v1-6-duplicate-rows-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LocaleIdentifier error when browsing SSAS cube via Management Studio</title>
		<link>http://www.dstewart.com.au/2011/10/localeidentifier-error-when-browsing-ssas-cube-via-management-studio/</link>
		<comments>http://www.dstewart.com.au/2011/10/localeidentifier-error-when-browsing-ssas-cube-via-management-studio/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 04:46:53 +0000</pubDate>
		<dc:creator><![CDATA[David Stewart]]></dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SSAS]]></category>
		<category><![CDATA[SSMS]]></category>

		<guid isPermaLink="false">http://110.232.142.10/~dstewart/?p=16</guid>
		<description><![CDATA[I can across an annoying error when using another client computer to connect to an Analysis Services cube via Management Studio. The error or received was &#8211; &#8220;The query could not be processed: XML for Analysis parser: The LocaleIdentifier property is not overwritable and cannot be assigned a new value.&#8221; To resolve this you can &#8230; <a href="http://www.dstewart.com.au/2011/10/localeidentifier-error-when-browsing-ssas-cube-via-management-studio/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I can across an annoying error when using another client computer to connect to an Analysis Services cube via Management Studio. The error or received was &#8211; &#8220;The query could not be processed: XML for Analysis parser: The LocaleIdentifier property is not overwritable and cannot be assigned a new value.&#8221;</p>
<p style="text-align: center;"><a title="SSAS LocaleIdentifier Issue" href="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/ssas-language-1.png" rel="lightbox[ssasli1]"><img class="size-large wp-image-34 aligncenter" title="SSAS LocaleIdentifier Issue" src="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/ssas-language-1-1024x192.png" alt="SSAS LocaleIdentifier Issue" width="590" height="110" /></a></p>
<p>To resolve this you can simply select your language from the language drop down in the cube browse window.</p>
<p><a title="SSAS LocaleIdentifier Issue Resolution" href="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/ssas-language-2.png" rel="lightbox[ssasli2]"><img class="aligncenter size-large wp-image-36" title="SSAS LocaleIdentifier Issue Resolution" src="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/ssas-language-2-1024x319.png" alt="SSAS LocaleIdentifier Issue Resolution" width="590" height="183" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dstewart.com.au/2011/10/localeidentifier-error-when-browsing-ssas-cube-via-management-studio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting a List of Installed OLE DB Providers in .NET</title>
		<link>http://www.dstewart.com.au/2011/10/getting-a-list-of-installed-ole-db-providers-in-net/</link>
		<comments>http://www.dstewart.com.au/2011/10/getting-a-list-of-installed-ole-db-providers-in-net/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 13:03:51 +0000</pubDate>
		<dc:creator><![CDATA[David Stewart]]></dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[OLE DB]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://110.232.142.10/~dstewart/?p=6</guid>
		<description><![CDATA[Recently I was working on a little side project, where I needed to allow users to connect to a variety of data sources using several connection types &#8211; SQL Server, OLE DB and ODBC. Unless I wanted users to manually type in the OLE DB provider (errr&#8230; I had no intention of even doing this &#8230; <a href="http://www.dstewart.com.au/2011/10/getting-a-list-of-installed-ole-db-providers-in-net/">Read more <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently I was working on a little side project, where I needed to allow users to connect to a variety of data sources using several connection types &#8211; SQL Server, OLE DB and ODBC. Unless I wanted users to manually type in the OLE DB provider (errr&#8230; I had no intention of even doing this myself&#8230;) then I needed to populate a list of installed OLE DB providers on the current machine.</p>
<p>Having had very little experience in .NET programming I searched around a bit and found a few less the elegant solutions, but was surprised just how simple it was to do in the end. In fact there&#8217;s a class to do it&#8230; <a title="OleDbEnumerator" href="http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbenumerator.aspx" target="_blank">OleDbEnumerator</a></p>
<p>There&#8217;s a couple of methods of interest in the class &#8211; <a title="GetElements()" href="http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbenumerator.getelements.aspx" target="_blank">GetElements()</a> which returns a data table containing information about the installed OLE DB providers, and <a title="GetRootEnumerator()" href="http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbenumerator.getrootenumerator.aspx" target="_blank">GetRootEnumerator()</a> which returns a data reader with information about the installed OLE DB providers.</p>
<p>In a windows forms application, populating a data grid view is as simple as one line:</p>
<div class="codecolorer-container vbnet default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="vbnet codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-style: italic;">' Set the data source of the data grid view to the</span><br />
<span style="color: #008080; font-style: italic;">' data table returned by GetElements()</span><br />
DataGridView1.<span style="color: #0000FF;">DataSource</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> OleDbEnumerator<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetElements</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div></td></tr></tbody></table></div>
<p>The resulting data grid view is shown below.</p>
<p><a href="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/ole-db-providers.png" title="OLE DB Provider List" rel="lightbox[oledbproviderlist]"><img class="aligncenter size-full wp-image-40" title="OLE DB Provider List" src="http://110.232.142.10/~dstewart/wp-content/uploads/2011/10/ole-db-providers.png" alt="OLE DB Provider List" width="870" height="550" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dstewart.com.au/2011/10/getting-a-list-of-installed-ole-db-providers-in-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
