<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SSIS Junkie : collation</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/tags/collation/default.aspx</link><description>Tags: collation</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Mind that collation : SSAS</title><link>http://sqlblog.com/blogs/jamie_thomson/archive/2010/02/15/mind-that-collation-ssas.aspx</link><pubDate>Mon, 15 Feb 2010 19:29:45 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:22312</guid><dc:creator>jamiet</dc:creator><slash:comments>3</slash:comments><comments>http://sqlblog.com/blogs/jamie_thomson/comments/22312.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/jamie_thomson/commentrss.aspx?PostID=22312</wfw:commentRss><wfw:comment>http://sqlblog.com/blogs/jamie_thomson/rsscomments.aspx?PostID=22312</wfw:comment><description>&lt;p&gt;I’ve been using Analysis Services a lot lately in my current day job and recently encountered an issue that I believe people need to be aware of. The issue transpired to be a bug in our application rather than in Analysis Services itself but it was brought about by a misunderstanding of how Analysis Services handles uniqueness for dimension attributes and its worth highlighting the issue here.&lt;/p&gt;  &lt;p&gt;I’ll demonstrate with a simple demo. Take this very simple [Product] dimension table:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/producttable_33E58A6F.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="product table" border="0" alt="product table" src="http://sqlblog.com/blogs/jamie_thomson/producttable_thumb_6CAFBE6F.png" width="327" height="109" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We only have two products in here but note the [ProductCategory], both have the same value of “fruit” but they have different case-sensitivity. As far as SQL Server is concerned those values are the same because I have set it to have a case-insensitive collation:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/sqlcollation_2C0D7200.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="sql server collation" border="0" alt="sql server collation" src="http://sqlblog.com/blogs/jamie_thomson/sqlcollation_thumb_2AC8D921.png" width="478" height="261" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note: The CI of Latin_General_CI_AS stands for case-insensitive&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Analysis Services on the other hand has a case-sensitive collation:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/ssascollation_29F07337.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="analysis services collation" border="0" alt="analysis services collation" src="http://sqlblog.com/blogs/jamie_thomson/ssascollation_thumb_545CA454.png" width="465" height="281" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Onto that Analysis server I have deployed a [Product] dimension that has [Product Category] as an attribute:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/productdim_01719123.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="product dimension" border="0" alt="product dimension" src="http://sqlblog.com/blogs/jamie_thomson/productdim_thumb_4BF8CEFD.png" width="219" height="159" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;And when I process that dimension I get an error:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;Errors in the OLAP storage engine: The attribute key cannot be found when processing: Table: 'dbo_Product', Column: 'ProductCategory', Value: 'fruit'. The attribute is 'Product Category'. Errors in the OLAP storage engine: An error occurred while the 'Product' attribute of the 'Product' dimension from the 'SSAS Collation Demo' database was being processed.&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/processingerror_406311BE.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="dimension processing error" border="0" alt="dimension processing error" src="http://sqlblog.com/blogs/jamie_thomson/processingerror_thumb_5F39859C.png" width="617" height="439" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;OK, so what’s going on here? Well fundamentally the problem is that our SQL Server and Analysis Server are using different collations. Analysis Services asks SQL Server to give it a distinct list of [ProductCategory] and SQL Server responds by giving back a single value (‘Fruit’) and hence our [Product Category] attribute only has one member. When Analysis Services attempts to process the its key attribute (i.e. [Product]) it tries to specify the relationship between the two members and the appropriate member in the [Product Category] attribute; it fails to do that because ‘fruit’ does not exist (because Analysis Services is using a case-sensitive collation) and thus we get a processing error.&lt;/p&gt;  &lt;p&gt;You may think that the simple solution would be to change the collation of our Analysis Server but in fact that probably is not the correct course of action. What we should do is change our [Product Category] attribute so that instead of being uniquely identified by the [Product].[Product Category] field it is instead uniquely identified by [Product].[ProductId]. In other words our dimension changes from this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/productdimdefinition_prior_703DB37F.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="product dimension definition prior" border="0" alt="product dimension definition prior" src="http://sqlblog.com/blogs/jamie_thomson/productdimdefinition_prior_thumb_76848A0D.png" width="444" height="365" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;to this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/jamie_thomson/productdimdefinition_post_3C954721.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="product dimension definition post" border="0" alt="product dimension definition post" src="http://sqlblog.com/blogs/jamie_thomson/productdimdefinition_post_thumb_3509D7B4.png" width="442" height="402" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Note the change in the &lt;strong&gt;&lt;font color="#004080"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#800000"&gt;ColumnID&lt;/font&gt;&lt;font color="#004080"&gt;&amp;gt;&lt;/font&gt;&lt;/strong&gt; property.&lt;/p&gt;  &lt;p&gt;After that, it all works because our unique list of [Product Category] is defined by [Product][ProductId] instead of [Product].[ProductCategory]!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;I hope this has been useful to you. Its important to know about collations when SQL Server and Analysis Services are communicating with each other and hopefully this post serves to heighten the awareness.&lt;/p&gt;  &lt;p&gt;Incidentally, this situation could probably be mitigated by normalising [ProductCategory] into a dimension table all of its own but given the lambasting I received &lt;a href="http://sqlblog.com/blogs/jamie_thomson/archive/2009/11/28/debunking-kimball-effective-dates.aspx"&gt;last time I fired a shot across Kimball’s bows&lt;/a&gt; I think I’ll leave that one well alone :)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://twitter.com/jamiet"&gt;@Jamiet&lt;/a&gt;&lt;/p&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=22312" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server/default.aspx">sql server</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/SSAS/default.aspx">SSAS</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/sql+server+analysis+services/default.aspx">sql server analysis services</category><category domain="http://sqlblog.com/blogs/jamie_thomson/archive/tags/collation/default.aspx">collation</category></item></channel></rss>