{"id":39,"date":"2007-11-21T23:28:13","date_gmt":"2007-11-22T04:28:13","guid":{"rendered":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/39_katmai-analysis-services-2008-november-ctp5-tests-on-metadata-rowsets"},"modified":"2008-03-17T20:44:13","modified_gmt":"2008-03-18T01:44:13","slug":"katmai-analysis-services-2008-november-ctp5-tests-on-metadata-rowsets","status":"publish","type":"post","link":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/39_katmai-analysis-services-2008-november-ctp5-tests-on-metadata-rowsets","title":{"rendered":"Katmai Analysis Services 2008 November CTP5 &#8211; tests on metadata rowsets"},"content":{"rendered":"<p>In SSAS 2005\u00a0to access SSAS metadata you had to use object model. \u00a0In SSAS 2008 November CTP Microsoft introduced schema rowsets as an alternative way to access metadata. I did some tests last few days and here I&#8217;ll post examples of what could be done. Generally it is quite easy to write these queries. BOL already have description for most of the tables and fields you can query. What was not so easy is to get metadata on structure that is hierarchical. That is there is an easy way to get a list of hierarchies in one dimension. But to get list of levels of hierarchies of dimensions becomes not an easy task.<\/p>\n<p>SELECT statements you can write on these rowsets appear to be quite limited. For example:<\/p>\n<ul>\n<li>SELECT DISTINCT does not return DISTINCT values<\/li>\n<li>ORDER BY clause accepts just one field to order by. Adding second field raises error: &#8220;Error (Data mining): Only one order expression is allowed for TOP expression at line 1, column 1&#8221;<\/li>\n<li>COUNT, SUM does not work<\/li>\n<li>WHERE clause works<\/li>\n<li>ORDER BY\u00a0&lt;number&gt; does not ORDER, but no error<\/li>\n<li>JOINS appear not to work<\/li>\n<li>LIKE does not work<\/li>\n<li>string functions like LEFT do not work<\/li>\n<\/ul>\n<p>As I did not find restriction list in documentation, list above is from my experience. It could be that I just did not do my tests properly, but I am sure sooner or latter there will be official list of what is supported.<\/p>\n<p>Bellow are examples of\u00a0 queries that are very simple, but enough for anyone to get an idea of what it is possible. All these examples where run in Adventure Works DW database.<\/p>\n<p><!--more--><\/p>\n<p><strong>Examples how to get metadata<\/strong><\/p>\n<blockquote><p>&#8212; List of cubes in current database<br \/>\nSELECT CUBE_NAME<br \/>\n\u00a0, BASE_CUBE_NAME &#8212; For perspective this will show source cube name<br \/>\n\u00a0 FROM $system.MDSCHEMA_CUBES<br \/>\n\u00a0WHERE CUBE_SOURCE = 1 &#8212; Just cubes, =2 &#8211; dimensions.<\/p><\/blockquote>\n<p><img loading=\"lazy\" width=\"269\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post39\/01-cubelist.jpg\" height=\"182\" style=\"width: 269px; height: 182px\" \/><\/p>\n<blockquote><p>&#8212; Show dimension in one cube or perspective<br \/>\nSELECT DIMENSION_ORDINAL<br \/>\n\u00a0, DIMENSION_NAME<br \/>\n\u00a0, DIMENSION_CARDINALITY<br \/>\n\u00a0, DEFAULT_HIERARCHY<br \/>\n\u00a0 FROM $SYSTEM.MDSCHEMA_DIMENSIONS<br \/>\n\u00a0WHERE CUBE_NAME = &#8216;Direct Sales&#8217; &#8212; Perspective name<br \/>\nORDER BY DIMENSION_ORDINAL<\/p><\/blockquote>\n<p><img loading=\"lazy\" width=\"616\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post39\/02-dimlist.jpg\" height=\"266\" style=\"width: 616px; height: 266px\" \/><\/p>\n<blockquote><p>&#8212; Show measuregroups in one cube or perspective<br \/>\nSELECT CUBE_NAME, MEASUREGROUP_NAME<br \/>\n\u00a0 FROM $SYSTEM.MDSCHEMA_MEASUREGROUPS<br \/>\n\u00a0WHERE CUBE_NAME = &#8216;Direct Sales&#8217;<\/p><\/blockquote>\n<p><img loading=\"lazy\" width=\"267\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post39\/03-mglist.jpg\" height=\"145\" style=\"width: 267px; height: 145px\" \/><br \/>\n\u00a0<\/p>\n<blockquote><p>&#8212; Show dimensions related to one measure group<br \/>\nSELECT CUBE_NAME, MEASUREGROUP_NAME, [DIMENSION_UNIQUE_NAME]<br \/>\n\u00a0, DIMENSION_IS_VISIBLE<br \/>\n\u00a0, DIMENSION_GRANULARITY<br \/>\n\u00a0 FROM $SYSTEM.MDSCHEMA_MEASUREGROUP_DIMENSIONS<br \/>\n\u00a0WHERE CUBE_NAME = &#8216;Direct Sales&#8217;<br \/>\n\u00a0\u00a0 AND MEASUREGROUP_NAME = &#8216;Internet Customers&#8217;<\/p><\/blockquote>\n<p><img loading=\"lazy\" width=\"744\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post39\/04-dimmglist.jpg\" height=\"237\" style=\"width: 744px; height: 237px\" \/><\/p>\n<blockquote><p>&#8212; Show available KPIs<br \/>\nSELECT CUBE_NAME, MEASUREGROUP_NAME, KPI_NAME<br \/>\n\u00a0, KPI_DESCRIPTION<br \/>\n\u00a0, KPI_VALUE<br \/>\n&#8212;\u00a0, KPI_GOAL\u00a0, KPI_STATUS\u00a0, KPI_TREND &#8212; etc<br \/>\n\u00a0 FROM $SYSTEM.MDSCHEMA_KPIS<br \/>\n\u00a0WHERE CUBE_NAME = &#8216;Direct Sales&#8217;<\/p><\/blockquote>\n<p><img loading=\"lazy\" width=\"695\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post39\/05-kpilist.jpg\" height=\"88\" style=\"width: 695px; height: 88px\" \/><\/p>\n<blockquote><p>&#8212; List of hierarchies in one dimension<br \/>\nSELECT [DIMENSION_UNIQUE_NAME]<br \/>\n\u00a0, HIERARCHY_NAME<br \/>\n\u00a0, [DEFAULT_MEMBER]<br \/>\n\u00a0 FROM $SYSTEM.MDSCHEMA_HIERARCHIES<br \/>\n\u00a0WHERE [DIMENSION_UNIQUE_NAME] = &#8216;[Account]&#8217; &#8212; Dimension unique name (should be in []&#8217;<br \/>\n\u00a0\u00a0 AND CUBE_NAME = &#8216;$Account&#8217; &#8212; Dimension could be used in multiple cubes. This enforces just dimension cube<br \/>\nORDER BY HIERARCHY_ORDINAL<\/p><\/blockquote>\n<p><img loading=\"lazy\" width=\"526\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post39\/06-hierlist.jpg\" height=\"125\" style=\"width: 526px; height: 125px\" \/><\/p>\n<p><strong>Examples how to query data<\/strong><\/p>\n<p>You can also write queries to get actual dimension members from dimension or\u00a0fact records from measure group. I found that performance on measure group queries was quite slow.<\/p>\n<p>So more examples:<\/p>\n<blockquote><p>&#8212; SELECT members from Account dimension<br \/>\nSELECT * FROM [$Account].[$Account]<\/p><\/blockquote>\n<p><img loading=\"lazy\" width=\"586\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post39\/07-account.jpg\" height=\"280\" style=\"width: 586px; height: 280px\" \/><\/p>\n<blockquote><p>&#8211;SELECT records from [Exchange Rates] measure group in [Direct Sales] perspective<br \/>\nSELECT * FROM [Direct Sales].[Exchange Rates]<\/p><\/blockquote>\n<p><img loading=\"lazy\" width=\"685\" src=\"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/BlogFiles\/Post39\/08-exch.jpg\" height=\"277\" style=\"width: 685px; height: 277px\" \/><\/p>\n<p>These examples should give you good idea what kind of metadata and data is now accessible.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In SSAS 2005\u00a0to access SSAS metadata you had to use object model. \u00a0In SSAS 2008 November CTP Microsoft introduced schema rowsets as an alternative way to access metadata. I did some tests last few days and here I&#8217;ll post examples of what could be done. Generally it is quite easy to write these queries. BOL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,6],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/posts\/39"}],"collection":[{"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":0,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ssas-info.com\/VidasMatelisBlog\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}