<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:gd="http://schemas.google.com/g/2005" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;Ck8HQ384eip7ImA9WhdSE0o.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503</id><updated>2011-07-22T22:40:32.132+01:00</updated><title>BI Log</title><subtitle type="html">Business Intelligence related blog posts.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://bi-logger.blogspot.com/" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>20</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/BiLog" /><feedburner:info uri="bilog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>BiLog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;DEECSHg-eCp7ImA9WhdTFEg.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-3080597188313824647</id><published>2011-07-12T08:44:00.000+01:00</published><updated>2011-07-12T08:44:29.650+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-12T08:44:29.650+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Analysis Services" /><category scheme="http://www.blogger.com/atom/ns#" term="ProcessAdd" /><title>Implementing Analysis Services Process Add Functionality – Part 3</title><content type="html">&lt;style&gt;
&lt;!--
 /* Font Definitions */
@font-face
 {font-family:"Courier New";
 panose-1:2 7 3 9 2 2 5 2 4 4;
 mso-font-charset:0;
 mso-generic-font-family:auto;
 mso-font-pitch:variable;
 mso-font-signature:3 0 0 0 1 0;}
@font-face
 {font-family:Cambria;
 panose-1:2 4 5 3 5 4 6 3 2 4;
 mso-font-charset:0;
 mso-generic-font-family:auto;
 mso-font-pitch:variable;
 mso-font-signature:3 0 0 0 1 0;}
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
 {mso-style-parent:"";
 margin:0cm;
 margin-bottom:.0001pt;
 mso-pagination:widow-orphan;
 font-size:12.0pt;
 font-family:"Times New Roman";
 mso-ascii-font-family:Cambria;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:Cambria;
 mso-fareast-theme-font:minor-latin;
 mso-hansi-font-family:Cambria;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;}
a:link, span.MsoHyperlink
 {color:blue;
 text-decoration:underline;
 text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
 {mso-style-noshow:yes;
 color:purple;
 text-decoration:underline;
 text-underline:single;}
pre
 {mso-style-link:"HTML Preformatted Char";
 margin:0cm;
 margin-bottom:.0001pt;
 mso-pagination:widow-orphan;
 font-size:10.0pt;
 font-family:Courier;
 mso-fareast-font-family:Cambria;
 mso-fareast-theme-font:minor-latin;
 mso-bidi-font-family:Courier;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
 {margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 mso-add-space:auto;
 mso-pagination:widow-orphan;
 font-size:12.0pt;
 font-family:"Times New Roman";
 mso-ascii-font-family:Cambria;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:Cambria;
 mso-fareast-theme-font:minor-latin;
 mso-hansi-font-family:Cambria;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst
 {mso-style-type:export-only;
 margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 mso-add-space:auto;
 mso-pagination:widow-orphan;
 font-size:12.0pt;
 font-family:"Times New Roman";
 mso-ascii-font-family:Cambria;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:Cambria;
 mso-fareast-theme-font:minor-latin;
 mso-hansi-font-family:Cambria;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;}
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle
 {mso-style-type:export-only;
 margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 mso-add-space:auto;
 mso-pagination:widow-orphan;
 font-size:12.0pt;
 font-family:"Times New Roman";
 mso-ascii-font-family:Cambria;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:Cambria;
 mso-fareast-theme-font:minor-latin;
 mso-hansi-font-family:Cambria;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;}
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast
 {mso-style-type:export-only;
 margin-top:0cm;
 margin-right:0cm;
 margin-bottom:0cm;
 margin-left:36.0pt;
 margin-bottom:.0001pt;
 mso-add-space:auto;
 mso-pagination:widow-orphan;
 font-size:12.0pt;
 font-family:"Times New Roman";
 mso-ascii-font-family:Cambria;
 mso-ascii-theme-font:minor-latin;
 mso-fareast-font-family:Cambria;
 mso-fareast-theme-font:minor-latin;
 mso-hansi-font-family:Cambria;
 mso-hansi-theme-font:minor-latin;
 mso-bidi-font-family:"Times New Roman";
 mso-bidi-theme-font:minor-bidi;}
span.HTMLPreformattedChar
 {mso-style-name:"HTML Preformatted Char";
 mso-style-locked:yes;
 mso-style-link:"HTML Preformatted";
 mso-ansi-font-size:10.0pt;
 mso-bidi-font-size:10.0pt;
 font-family:Courier;
 mso-ascii-font-family:Courier;
 mso-hansi-font-family:Courier;
 mso-bidi-font-family:Courier;}
span.moz-txt-citetags
 {mso-style-name:moz-txt-citetags;}
@page Section1
 {size:612.0pt 792.0pt;
 margin:72.0pt 90.0pt 72.0pt 90.0pt;
 mso-header-margin:36.0pt;
 mso-footer-margin:36.0pt;
 mso-paper-source:0;}
div.Section1
 {page:Section1;}
 /* List Definitions */
@list l0
 {mso-list-id:777870908;
 mso-list-template-ids:857012422;}
@list l0:level1
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l0:level2
 {mso-level-number-format:alpha-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l0:level3
 {mso-level-number-format:roman-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:right;
 text-indent:-9.0pt;}
@list l0:level4
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l0:level5
 {mso-level-number-format:alpha-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l0:level6
 {mso-level-number-format:roman-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:right;
 text-indent:-9.0pt;}
@list l0:level7
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l0:level8
 {mso-level-number-format:alpha-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l0:level9
 {mso-level-number-format:roman-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:right;
 text-indent:-9.0pt;}
@list l1
 {mso-list-id:1333097237;
 mso-list-template-ids:-480072042;}
@list l1:level1
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l1:level2
 {mso-level-number-format:alpha-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l1:level3
 {mso-level-number-format:roman-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:right;
 text-indent:-9.0pt;}
@list l1:level4
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l1:level5
 {mso-level-number-format:alpha-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l1:level6
 {mso-level-number-format:roman-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:right;
 text-indent:-9.0pt;}
@list l1:level7
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l1:level8
 {mso-level-number-format:alpha-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l1:level9
 {mso-level-number-format:roman-lower;
 mso-level-tab-stop:none;
 mso-level-number-position:right;
 text-indent:-9.0pt;}
@list l2
 {mso-list-id:1376854260;
 mso-list-type:hybrid;
 mso-list-template-ids:-480072042 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l2:level1
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l3
 {mso-list-id:1456826996;
 mso-list-type:hybrid;
 mso-list-template-ids:1636854432 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l3:level1
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l4
 {mso-list-id:1481536340;
 mso-list-type:hybrid;
 mso-list-template-ids:-480072042 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l4:level1
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
@list l5
 {mso-list-id:1933468725;
 mso-list-type:hybrid;
 mso-list-template-ids:857012422 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l5:level1
 {mso-level-tab-stop:none;
 mso-level-number-position:left;
 text-indent:-18.0pt;}
ol
 {margin-bottom:0cm;}
ul
 {margin-bottom:0cm;}
--&gt;
&lt;/style&gt;     &lt;br /&gt;
&lt;div class="MsoNormal"&gt;Following on from my previous post, which can be found &lt;a href="http://bi-logger.blogspot.com/2011/05/implementing-analysis-services-process.html"&gt;&lt;span style="color: black;"&gt;here&lt;/span&gt;&lt;/a&gt;, where I presented one solution for implementing process add functionality, I’ll try to cover off some functional code in order to implement this. Clearly this code can be enhanced and/or converted to your specific needs but hopefully this is a start.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;First let’s setup a dummy set of tables to represent a customer dimension. &lt;i&gt;(Apologies for the formatting, will fix once I can edit my templates again.)&lt;/i&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-size: 14pt;"&gt;Dummy Tables&lt;/span&gt;&lt;/b&gt; &lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ANSI_NULLS&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;QUOTED_IDENTIFIER&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;NOCOUNT&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* Delete objects.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[customer]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [type] &lt;span style="color: grey;"&gt;in&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'U'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[address]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [type] &lt;span style="color: grey;"&gt;in&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'U'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[address]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[customer_group]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [type] &lt;span style="color: grey;"&gt;in&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'U'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_group]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[customer_class]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [type] &lt;span style="color: grey;"&gt;in&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'U'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_class]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* CUSTOMER CLASS table.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_class]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_class_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: blue;"&gt;IDENTITY&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt; &lt;span style="color: blue;"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: blue;"&gt;CLUSTERED&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_class_name] &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;50&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;)&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; [PRIMARY]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_class] &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_class] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[customer_class_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_class_name]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Class1'&lt;/span&gt;&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_class] &lt;span style="color: blue;"&gt;OFF&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* CUSTOMER GROUP table.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_group]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_group_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: blue;"&gt;IDENTITY&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt; &lt;span style="color: blue;"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: blue;"&gt;CLUSTERED&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_group_name] &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;50&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_class_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [fk_customer_group_customer_class]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;REFERENCES&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_class] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[customer_class_id]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;)&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; [PRIMARY]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_group] &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_group] &lt;span style="color: grey;"&gt;( &lt;/span&gt;[customer_group_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_group_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;[customer_class_id] &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Group1'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_group] &lt;span style="color: grey;"&gt;( &lt;/span&gt;[customer_group_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_group_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;[customer_class_id] &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;2&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Group2'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_group] &lt;span style="color: blue;"&gt;OFF&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* ADDRESS table.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[address]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [address_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: blue;"&gt;IDENTITY&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt; &lt;span style="color: blue;"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: blue;"&gt;CLUSTERED&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [address_line_1] &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;50&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [address_line_2] &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;50&lt;span style="color: grey;"&gt;)&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;)&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; [PRIMARY]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[address] &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[address] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[address_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_line_1]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_line_2]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(-&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Unknown'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[address] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[address_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_line_1]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_line_2]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'House 1'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Street 1'&lt;/span&gt;&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[address] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[address_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_line_1]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_line_2]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;2&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'House 2'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[address] &lt;span style="color: blue;"&gt;OFF&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* CUSTOMER table.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: blue;"&gt;IDENTITY&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt; &lt;span style="color: blue;"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: blue;"&gt;CLUSTERED&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_name] &lt;span style="color: blue;"&gt;VARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;50&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [address_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [fk_customer_address]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;REFERENCES&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[address]&lt;span style="color: grey;"&gt;(&lt;/span&gt;[address_id]&lt;span style="color: grey;"&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_group_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [fk_customer_customer_group]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;REFERENCES&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_group]&lt;span style="color: grey;"&gt;(&lt;/span&gt;[customer_group_id]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;)&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; [PRIMARY]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer] &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[customer_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_group_id]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Customer 1'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[customer_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_group_id]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;2&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Customer 2'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: grey;"&gt;-&lt;/span&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[customer_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_group_id]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;3&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Customer 3'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; 2&lt;span style="color: grey;"&gt;,&lt;/span&gt; 2&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer] &lt;span style="color: blue;"&gt;OFF&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Now, taking each of the steps in turn…&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-size: 14pt;"&gt;The Seven-And-A-Half Steps to Process Add&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;Step 1&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;First we need to capture the list of dimensions we are interested in and the associated key table for that dimension. Note that by “key table”, I’m referring to the table that contains the attribute to be used as the key in the dimension. The following code will create a table that captures this information.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* LIST OF DIMENSIONS&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[dimension]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [type] &lt;span style="color: grey;"&gt;in&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'U'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension]&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: blue;"&gt;IDENTITY&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt;1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [pk_dimension] &lt;span style="color: blue;"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: blue;"&gt;CLUSTERED&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [olap_dimension_id] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [uk_dimension] &lt;span style="color: blue;"&gt;UNIQUE&lt;/span&gt; &lt;span style="color: blue;"&gt;NONCLUSTERED&lt;/span&gt; &lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_name] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;)&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; [PRIMARY]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;Step 1a&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;For performance reasons we will create a table in which we will capture the names of all the tables used by a given. (i.e. The key table and recursively all related tables.)&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* DIMENSION TABLE RELATIONSHIP&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[dimension_table_relationship]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [type] &lt;span style="color: grey;"&gt;in&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'U'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_table_relationship]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_table_relationship]&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_table_relationship_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: blue;"&gt;IDENTITY&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt;1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [pk_dimension_table_relationship] &lt;span style="color: blue;"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: blue;"&gt;CLUSTERED&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_id] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [fk_dimension_table_relationship_dimension_dimension]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;REFERENCES&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension]&lt;span style="color: grey;"&gt;(&lt;/span&gt;[dimension_id]&lt;span style="color: grey;"&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [olap_dimension_id] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [fk_dimension_table_relationship_dimension_olap]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;span style="color: blue;"&gt;REFERENCES&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension]&lt;span style="color: grey;"&gt;(&lt;/span&gt;[olap_dimension_id]&lt;span style="color: grey;"&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_key_table_schema] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_key_table_name] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [attribute_table_schema] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [attribute_table_name] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [first_referencing_table_schema] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [first_referencing_table_name] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;)&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; [PRIMARY]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;Step 2&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Next we need to create a table in which we will capture the names of all the tables used by a given dimension on rows. (i.e. The key table and all related tables.) as well as the previous and current identity values for each table.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; &lt;span style="color: magenta;"&gt;object_id&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[dimension_process_attribute_key_range]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: blue;"&gt;type&lt;/span&gt; &lt;span style="color: grey;"&gt;in&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'U'&lt;/span&gt;&lt;span style="color: grey;"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range]&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_process_attribute_key_range_key] &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: blue;"&gt;IDENTITY&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt;1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CONSTRAINT&lt;/span&gt; [pk_dimension_process_attribute_key_range] &lt;span style="color: blue;"&gt;PRIMARY&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: blue;"&gt;CLUSTERED&lt;/span&gt; &lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [olap_dimension_id] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_key_table_schema] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_key_table_name] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [attribute_table_schema] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [attribute_table_name] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [min_key_value] &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [max_key_value] &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [new_data_flag] &lt;span style="color: blue;"&gt;BIT&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [process_flag] &lt;span style="color: blue;"&gt;BIT&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [created_date] &lt;span style="color: blue;"&gt;DATETIME&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [created_by] &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;255&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [updated_date] &lt;span style="color: blue;"&gt;DATETIME&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [updated_by] &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;255&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;)&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; [PRIMARY]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;Step 3&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Populate the tables created in point 1 and 1a above with the dimensions for which you wish to use process add and where the underlying relational schema has been configured as described in the previous posts.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension] &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[dimension_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [olap_dimension_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [dimension_name] &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;IDENTITY_INSERT&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension] &lt;span style="color: blue;"&gt;OFF&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;span style="font-size: xx-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_table_relationship] &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;( &lt;/span&gt;[dimension_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [olap_dimension_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[dimension_key_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [dimension_key_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[attribute_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [attribute_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[first_referencing_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [first_referencing_table_name] &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;1&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'Customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;span style="font-size: xx-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;Step 4&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Create a stored procedure that accepts a given dimension name and key table name and, using the information schema views etc, identify all related tables by means of foreign key relationships.&lt;table_name&gt; If you did not create foreign keys between all tables, you will need statically capture all tables used by a given dimension and maintain this over time as tables are added or dropped.&lt;/table_name&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ANSI_NULLS&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;QUOTED_IDENTIFIER&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; &lt;span style="color: magenta;"&gt;object_id&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[usp_reseed_dimension_table_relationship_by_dimension]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: blue;"&gt;type&lt;/span&gt; &lt;span style="color: grey;"&gt;in&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'P'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; N&lt;span style="color: red;"&gt;'PC'&lt;/span&gt;&lt;span style="color: grey;"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;PROCEDURE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[usp_reseed_dimension_table_relationship_by_dimension]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;PROCEDURE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[usp_reseed_dimension_table_relationship_by_dimension]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;@i_DimensionID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @i_DimensionKeyTableSchema &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@i_DimensionKeyTableName&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;AS&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* Recursively captures all tables related to the table passed into the&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* stored procedure. Essentially it recursively captures the attribute&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* relationships from a given "dimension key" table.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* Input Parameters:&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* ----------------&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* @i_DimensionID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The relational identifier for the dimension for&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; which attribute relationships are required.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* @i_DimensionKeyTableSchema The schema in which the dimension key table&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resides.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* @i_DimensionKeyTableName&amp;nbsp;&amp;nbsp; The name of the table from which all related&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tables should be derived.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* Ver&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Author&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Comments&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* ---&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -------------------&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----------&amp;nbsp; ------------------------------&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Philip Stephenson&amp;nbsp;&amp;nbsp; 11-Mar-2011&amp;nbsp; Original version.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;NOCOUNT&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;DECLARE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: green;"&gt;-- Define Error Codes.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ERR_MISSING_PARAM&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ERR_GENERAL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;-- Define user variables.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ErrCode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ErrMsg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;MAX&lt;/span&gt;&lt;span style="color: grey;"&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @StepNbr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SMALLINT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @FQProcedureName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;392&lt;span style="color: grey;"&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @RetVal&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @NewLine&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;MAX&lt;/span&gt;&lt;span style="color: grey;"&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @OlapDimensionID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @RowsAffected&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * STEP 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * Set variables.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ERR_MISSING_PARAM &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ERR_GENERAL &lt;span style="color: grey;"&gt;=&lt;/span&gt; 128&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrCode &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @FQProcedureName &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;QUOTENAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;DB_NAME&lt;/span&gt;&lt;span style="color: grey;"&gt;())&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;'.'&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;QUOTENAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;OBJECT_SCHEMA_NAME&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;@@PROCID&lt;/span&gt;&lt;span style="color: grey;"&gt;))&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;'.'&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;QUOTENAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;OBJECT_NAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;@@PROCID&lt;/span&gt;&lt;span style="color: grey;"&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;=&lt;/span&gt; N&lt;span style="color: red;"&gt;'ERROR - Stored procedure '&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; @FQProcedureName &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;' '&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @NewLine &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;NCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;13&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: blue;"&gt;NCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;10&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: green;"&gt;-- Capture the OLAP dimension ID for the dimension ID provided.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; @OlapDimensionID &lt;span style="color: grey;"&gt;=&lt;/span&gt; [olap_dimension_id]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @i_DimensionID&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: green;"&gt;-- Set the default rows affected count.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @RowsAffected &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: grey;"&gt;-&lt;/span&gt;1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * STEP 2&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * Ensure that the dimension ID parameter is not NULL and that a non-null olap&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * dimension ID was found.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;IF&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;@i_DimensionID &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt; &lt;span style="color: grey;"&gt;OR&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;@OlapDimensionID &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;'identified that either the given @i_DimensionID parameter (i.e. '&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;ISNULL&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;@i_DimensionID&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;span style="color: red;"&gt;'{null}'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;') was NULL or the associated [olap_dimension_id] was NULL. This is not allowed!'&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrCode &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ERR_MISSING_PARAM&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;GOTO&lt;/span&gt; FAIL&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * STEP 3&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * Ensure that the dimension key table schema parameter is not NULL.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;IF&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;@i_DimensionKeyTableSchema &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;'identified that the @i_DimensionKeyTableSchema parameter was NULL. This is not allowed!'&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrCode &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ERR_MISSING_PARAM&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;GOTO&lt;/span&gt; FAIL&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * STEP 4&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * Ensure that the dimension key table name parameter is not NULL.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;IF&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;@i_DimensionKeyTableName &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;'identified that the @i_DimensionKeyTableName parameter was NULL. This is not allowed!'&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrCode &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ERR_MISSING_PARAM&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;GOTO&lt;/span&gt; FAIL&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt; &lt;span style="color: blue;"&gt;TRY&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 5&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create temporary table, else truncate it if it already exists.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;IF&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'[tempdb].[dbo].[#foreign_key_tree]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [#foreign_key_tree]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [base_table_schema]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [base_table_name]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referenced_table_schema]&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referenced_table_name]&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referencing_table_schema] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referencing_table_name]&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;TRUNCATE&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [#foreign_key_tree]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 6&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Capture the starting point from which to recursively derive all related&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * tables.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [#foreign_key_tree] &lt;span style="color: grey;"&gt;(&lt;/span&gt; [base_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [base_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[referenced_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referenced_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[referencing_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[referencing_table_name] &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;VALUES&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;@i_DimensionKeyTableSchema&lt;span style="color: grey;"&gt;,&lt;/span&gt; @i_DimensionKeyTableName&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;@i_DimensionKeyTableSchema&lt;span style="color: grey;"&gt;,&lt;/span&gt; @i_DimensionKeyTableName&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;@i_DimensionKeyTableSchema&lt;span style="color: grey;"&gt;,&lt;/span&gt; @i_DimensionKeyTableName&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 7&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Recursively capture all tables related to the set of tables already in&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * the temporary table. The idea here is to obtain the set of all tables&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * that could be used by a dimension in Analysis Services.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHILE&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;@RowsAffected &lt;span style="color: grey;"&gt;&amp;lt;&amp;gt;&lt;/span&gt; 0&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [#foreign_key_tree] &lt;span style="color: grey;"&gt;(&lt;/span&gt; [base_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [base_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[referenced_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referenced_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[referencing_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[referencing_table_name] &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; inline&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_schema]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "base_table_schema"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inline&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_name]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "base_table_name"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inline&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "referenced_table_schema"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inline&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "referenced_table_name"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inline&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_schema] &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "referencing_table_schema"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inline&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_name]&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "referencing_table_name"&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: blue;"&gt;DISTINCT&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reftab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; reftab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_name]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;INFORMATION_SCHEMA.TABLES&lt;/span&gt; tab&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; &lt;span style="color: green;"&gt;INFORMATION_SCHEMA.TABLE_CONSTRAINTS&lt;/span&gt; con&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; tab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA] &lt;span style="color: grey;"&gt;=&lt;/span&gt; con&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME] &lt;span style="color: grey;"&gt;=&lt;/span&gt; con&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; &lt;span style="color: green;"&gt;INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE&lt;/span&gt; fctcol&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; tab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA] &lt;span style="color: grey;"&gt;=&lt;/span&gt; fctcol&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME] &lt;span style="color: grey;"&gt;=&lt;/span&gt; fctcol&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;con&lt;span style="color: grey;"&gt;.&lt;/span&gt;[CONSTRAINT_NAME] &lt;span style="color: grey;"&gt;=&lt;/span&gt; fctcol&lt;span style="color: grey;"&gt;.&lt;/span&gt;[CONSTRAINT_NAME]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; &lt;span style="color: green;"&gt;INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS&lt;/span&gt; rfc&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; con&lt;span style="color: grey;"&gt;.&lt;/span&gt;[CONSTRAINT_SCHEMA] &lt;span style="color: grey;"&gt;=&lt;/span&gt; rfc&lt;span style="color: grey;"&gt;.&lt;/span&gt;[CONSTRAINT_SCHEMA] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con&lt;span style="color: grey;"&gt;.&lt;/span&gt;[CONSTRAINT_NAME] &lt;span style="color: grey;"&gt;=&lt;/span&gt; rfc&lt;span style="color: grey;"&gt;.&lt;/span&gt;[CONSTRAINT_NAME]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; [CONSTRAINT_SCHEMA]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[CONSTRAINT_NAME]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[TABLE_SCHEMA]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[TABLE_NAME]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[COLUMN_NAME]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;UNION&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;-- Include unique indexes&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: magenta;"&gt;SCHEMA_NAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;obj&lt;span style="color: grey;"&gt;.&lt;/span&gt;[schema_id]&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "CONSTRAINT_SCHEMA"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; idx&lt;span style="color: grey;"&gt;.&lt;/span&gt;[name]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "CONSTRAINT_NAME"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: magenta;"&gt;SCHEMA_NAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;obj&lt;span style="color: grey;"&gt;.&lt;/span&gt;[schema_id]&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "TABLE_SCHEMA"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj&lt;span style="color: grey;"&gt;.&lt;/span&gt;[name]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "TABLE_NAME"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; col&lt;span style="color: grey;"&gt;.&lt;/span&gt;[name]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "COLUMN_NAME"&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.index_columns&lt;/span&gt; icl &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; &lt;span style="color: green;"&gt;sys.indexes&lt;/span&gt; idx&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; icl&lt;span style="color: grey;"&gt;.&lt;/span&gt;[index_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; idx&lt;span style="color: grey;"&gt;.&lt;/span&gt;[index_id]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt; obj&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; idx&lt;span style="color: grey;"&gt;.&lt;/span&gt;[object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; obj&lt;span style="color: grey;"&gt;.&lt;/span&gt;[object_id] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; icl&lt;span style="color: grey;"&gt;.&lt;/span&gt;[object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; obj&lt;span style="color: grey;"&gt;.&lt;/span&gt;[object_id]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; &lt;span style="color: green;"&gt;sys.columns&lt;/span&gt; col&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;ON&lt;/span&gt; obj&lt;span style="color: grey;"&gt;.&lt;/span&gt;[object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; col&lt;span style="color: grey;"&gt;.&lt;/span&gt;[object_id] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; icl&lt;span style="color: grey;"&gt;.&lt;/span&gt;[column_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; col&lt;span style="color: grey;"&gt;.&lt;/span&gt;[column_id]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; idx&lt;span style="color: grey;"&gt;.&lt;/span&gt;[is_unique] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1 &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; idx&lt;span style="color: grey;"&gt;.&lt;/span&gt;[is_primary_key] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0 &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj&lt;span style="color: grey;"&gt;.&lt;/span&gt;[is_ms_shipped] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0 &lt;span style="color: grey;"&gt;)&lt;/span&gt; refcol&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; rfc&lt;span style="color: grey;"&gt;.&lt;/span&gt;[UNIQUE_CONSTRAINT_SCHEMA] &lt;span style="color: grey;"&gt;=&lt;/span&gt; refcol&lt;span style="color: grey;"&gt;.&lt;/span&gt;[CONSTRAINT_SCHEMA] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rfc&lt;span style="color: grey;"&gt;.&lt;/span&gt;[UNIQUE_CONSTRAINT_NAME] &lt;span style="color: grey;"&gt;=&lt;/span&gt; refcol&lt;span style="color: grey;"&gt;.&lt;/span&gt;[CONSTRAINT_NAME]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; &lt;span style="color: green;"&gt;INFORMATION_SCHEMA.TABLES&lt;/span&gt; reftab&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; refcol&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA] &lt;span style="color: grey;"&gt;=&lt;/span&gt; reftab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; refcol&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME] &lt;span style="color: grey;"&gt;=&lt;/span&gt; reftab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; [#foreign_key_tree] tmp&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; tab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_name]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; tab&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_TYPE] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'BASE TABLE'&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; con&lt;span style="color: grey;"&gt;.&lt;/span&gt;[CONSTRAINT_TYPE] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'FOREIGN KEY'&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;)&lt;/span&gt; inline &lt;span style="color: grey;"&gt;LEFT&lt;/span&gt; &lt;span style="color: grey;"&gt;OUTER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; [#foreign_key_tree] nxt&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; inline&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_SCHEMA] &lt;span style="color: grey;"&gt;=&lt;/span&gt; nxt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inline&lt;span style="color: grey;"&gt;.&lt;/span&gt;[TABLE_NAME] &lt;span style="color: grey;"&gt;=&lt;/span&gt; nxt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_name]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; nxt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_name] &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;-- Capture the number of rows inserted.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @RowsAffected &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;@@ROWCOUNT&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 9&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Update current information in the static table.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; tgt&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; [first_referencing_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referencing_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [first_referencing_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referencing_table_name]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_table_relationship] tgt &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; [#foreign_key_tree] src&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @i_DimensionID &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @OlapDimensionID &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_name] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_name]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[first_referencing_table_schema] &lt;span style="color: grey;"&gt;&amp;lt;&amp;gt;&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referencing_table_schema] &lt;span style="color: grey;"&gt;OR&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[first_referencing_table_name] &lt;span style="color: grey;"&gt;&amp;lt;&amp;gt;&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referencing_table_name]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 9&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Insert new information into the static table.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_table_relationship]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;( &lt;/span&gt;[dimension_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [olap_dimension_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[dimension_key_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [dimension_key_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[attribute_table_schema]&lt;span style="color: grey;"&gt;, &lt;/span&gt;[attribute_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[first_referencing_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [first_referencing_table_name] &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; @i_DimensionID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "dimension_id"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @OlapDimensionID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "olap_dimension_id"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [base_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [base_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referenced_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referenced_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referencing_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referencing_table_name]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [#foreign_key_tree] src&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: grey;"&gt;LEFT&lt;/span&gt; &lt;span style="color: grey;"&gt;OUTER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_table_relationship] tgt&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @i_DimensionID &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @OlapDimensionID &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_name] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; src&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_name]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_table_relationship_id] &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 11&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Clean up.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;IF&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'[tempdb].[dbo].[#foreign_key_tree]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [#foreign_key_tree]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt; &lt;span style="color: blue;"&gt;TRY&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt; &lt;span style="color: blue;"&gt;CATCH&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrCode &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ERR_GENERAL&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;'raised error ('&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;CAST&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;ERROR_NUMBER&lt;/span&gt;&lt;span style="color: grey;"&gt;()&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;') in step number ('&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;CAST&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;@StepNbr &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;') at line number ('&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;CAST&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;ERROR_LINE&lt;/span&gt;&lt;span style="color: grey;"&gt;()&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;') with message: '&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;ERROR_MESSAGE&lt;/span&gt;&lt;span style="color: grey;"&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;GOTO&lt;/span&gt; FAIL&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt; &lt;span style="color: blue;"&gt;CATCH&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;GOTO&lt;/span&gt; SUCCESS&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;FAIL&lt;span style="color: grey;"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: green;"&gt;-- Cater for max exception string length.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;CASE&lt;/span&gt; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;LEN&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;@ErrMsg&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;&amp;gt;&lt;/span&gt; 2044&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; N&lt;span style="color: red;"&gt;'...'&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: grey;"&gt;RIGHT(&lt;/span&gt;@ErrMsg&lt;span style="color: grey;"&gt;,&lt;/span&gt; 2041&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt; &lt;span style="color: grey;"&gt;RIGHT(&lt;/span&gt;@ErrMsg&lt;span style="color: grey;"&gt;,&lt;/span&gt; 2044&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;RAISERROR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;@ErrMsg&lt;span style="color: grey;"&gt;,&lt;/span&gt; 16&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;IF&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'[tempdb].[dbo].[#foreign_key_tree]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [#foreign_key_tree]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;RETURN&lt;/span&gt; @ErrCode&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SUCCESS&lt;span style="color: grey;"&gt;:&lt;/span&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;RETURN&lt;/span&gt; 0&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;Step 5&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Create a stored procedure that uses the information captured by the SP created in step 4 above, to now populate the table created in point 2 above with an  arbitrary minimum value and, using the IDENT_CURRENT(‘’)  function, populate the max value with the current identity value for the  table&lt;style&gt;
. 
&lt;/style&gt;&lt;span style="font-family: Cambria; font-size: 12.0pt; mso-ansi-language: EN-GB; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Cambria; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;. Note that you must ensure that you retrieve the values for the key table &lt;i style="mso-bidi-font-style: normal;"&gt;before&lt;/i&gt; any of the related tables. This is what provides protection against the race condition discussed in my previous post&lt;/span&gt;.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ANSI_NULLS&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;QUOTED_IDENTIFIER&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; &lt;span style="color: magenta;"&gt;object_id&lt;/span&gt; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[usp_derive_new_attribute_keys_for_processing]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: blue;"&gt;type&lt;/span&gt; &lt;span style="color: grey;"&gt;in&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'P'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; N&lt;span style="color: red;"&gt;'PC'&lt;/span&gt;&lt;span style="color: grey;"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;PROCEDURE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[usp_derive_new_attribute_keys_for_processing]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;PROCEDURE&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[usp_derive_new_attribute_keys_for_processing]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;AS&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/**&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* For each dimension configured to be processed using "process add", capture the&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* set of new attribute keys for every attribute in the dimension.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* Ver&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Author&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Comments&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* ---&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -------------------&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----------&amp;nbsp; ------------------------------&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Philip Stephenson&amp;nbsp;&amp;nbsp; 01-Jul-2011&amp;nbsp; Original version.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;NOCOUNT&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;DECLARE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: green;"&gt;-- Define Error Codes.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ERR_GENERAL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ERR_LOOKUP_FAIL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;-- Define user variables.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ErrCode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INT&lt;/span&gt; &lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;span style="color: green;"&gt;--= 0,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ErrMsg&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;MAX&lt;/span&gt;&lt;span style="color: grey;"&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @StepNbr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SMALLINT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;span style="color: green;"&gt;-- = 0,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @FQProcedureName&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;392&lt;span style="color: grey;"&gt;),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @RetVal&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @AbsoluteMinKeyValue&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @AbsoluteMaxKeyValue&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @MinKeyValue&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @RowsAffected&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @ProcessAddFlag&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BIT&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * STEP 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; * Set variables.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ERR_GENERAL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;=&lt;/span&gt; 128&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ERR_LOOKUP_FAIL &lt;span style="color: grey;"&gt;=&lt;/span&gt; 512&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @FQProcedureName &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;QUOTENAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;DB_NAME&lt;/span&gt;&lt;span style="color: grey;"&gt;())&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;'.'&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;QUOTENAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;OBJECT_SCHEMA_NAME&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;@@PROCID&lt;/span&gt;&lt;span style="color: grey;"&gt;))&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: red;"&gt;'.'&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;QUOTENAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;OBJECT_NAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;@@PROCID&lt;/span&gt;&lt;span style="color: grey;"&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;=&lt;/span&gt; N&lt;span style="color: red;"&gt;'ERROR - Stored procedure '&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; @FQProcedureName &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;' '&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @AbsoluteMinKeyValue &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: grey;"&gt;-&lt;/span&gt;32768&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @AbsoluteMaxKeyValue &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: grey;"&gt;((&lt;/span&gt;&lt;span style="color: magenta;"&gt;POWER&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;CAST&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;2 &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt;&lt;span style="color: grey;"&gt;),&lt;/span&gt; 62&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;-&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; 2&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @MinKeyValue &lt;span style="color: grey;"&gt;=&lt;/span&gt; @AbsoluteMinKeyValue&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @RowsAffected &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: grey;"&gt;-&lt;/span&gt;1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt; &lt;span style="color: blue;"&gt;TRY&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 2&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Create temporary table, else truncate it if it already exists.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;IF&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'[tempdb].[dbo].[#foreign_key_tree]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CREATE&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [#foreign_key_tree]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [olap_dimension_id]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [base_table_schema]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [base_table_name]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referenced_table_schema] &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referenced_table_name]&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt; &lt;span style="color: blue;"&gt;COLLATE&lt;/span&gt; DATABASE_DEFAULT &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [new_min_key_value]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt;&amp;nbsp; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [min_key_value]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt;&amp;nbsp; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [max_key_value]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BIGINT&lt;/span&gt;&amp;nbsp; &lt;span style="color: grey;"&gt;NULL,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [process_add_flag]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BIT&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;TRUNCATE&lt;/span&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; [#foreign_key_tree]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 3&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Capture all tables (and their current identity column value) for all&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * dimensions set to be processed. The idea here is to obtain the set of&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;* all tables that could be used by a dimension in Analysis Services and&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * to capture the available keys.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [#foreign_key_tree] &lt;span style="color: grey;"&gt;(&lt;/span&gt; [olap_dimension_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [base_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[base_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [referenced_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [referenced_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [new_min_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[min_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [process_add_flag] &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_schema] &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "base_table_schema"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_name]&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "base_table_name"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "referenced_table_schema"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "referenced_table_name"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; atr&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value] &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "new_min_key_value"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @AbsoluteMinKeyValue&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "min_key_value"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: magenta;"&gt;IDENT_CURRENT&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;QUOTENAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema]&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;'.'&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;QUOTENAME&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name]&lt;span style="color: grey;"&gt;))&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "max_key_value"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "process_add_flag"&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_table_relationship] rel&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;LEFT&lt;/span&gt; &lt;span style="color: grey;"&gt;OUTER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range] atr&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; atr&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; atr&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; atr&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_name] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; atr&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rel&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; atr&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;atr&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 4&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Invert current (process flag = 1) and non-current (process flag = 0) rows,&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * updating related attributes appropriately.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; tgt&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; [process_flag]&amp;nbsp; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;CASE&lt;/span&gt; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1 &lt;span style="color: blue;"&gt;THEN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [min_key_value] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;CASE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;-- Update soon to be non-current record for ProcessAdd.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_add_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value] &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;-- Update soon to be current record for ProcessAdd when flipped from "non process add".&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_add_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[min_key_value] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @AbsoluteMinKeyValue&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value] &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;-- Update soon to be current record for ProcessUpdate/ProcessFull&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_add_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; @AbsoluteMinKeyValue&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[min_key_value]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [max_key_value] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [new_data_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;CASE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_add_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;((&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value] &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;ISNULL&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; @AbsoluteMaxKeyValue&lt;span style="color: grey;"&gt;))&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_add_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;@AbsoluteMinKeyValue &lt;span style="color: grey;"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;ISNULL&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; @AbsoluteMaxKeyValue&lt;span style="color: grey;"&gt;))&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_add_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[min_key_value] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @AbsoluteMinKeyValue&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;((&lt;/span&gt;non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value] &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;ISNULL&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; @AbsoluteMaxKeyValue&lt;span style="color: grey;"&gt;))&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_add_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[min_key_value] &lt;span style="color: grey;"&gt;&amp;lt;&amp;gt;&lt;/span&gt; @AbsoluteMinKeyValue&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[min_key_value] &lt;span style="color: grey;"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;ISNULL&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; @AbsoluteMaxKeyValue&lt;span style="color: grey;"&gt;))&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_add_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 0&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[min_key_value] &lt;span style="color: grey;"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;ISNULL&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; @AbsoluteMaxKeyValue&lt;span style="color: grey;"&gt;))&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [updated_date]&amp;nbsp; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;GETDATE&lt;/span&gt;&lt;span style="color: grey;"&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [updated_by]&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;ORIGINAL_LOGIN&lt;/span&gt;&lt;span style="color: grey;"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range] tgt&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;LEFT&lt;/span&gt; &lt;span style="color: grey;"&gt;OUTER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range] non&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_name] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;&amp;lt;&amp;gt;&lt;/span&gt; non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; [#foreign_key_tree] tmp&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_name] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_name]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt; &lt;span style="color: grey;"&gt;OR&lt;/span&gt; &lt;span style="color: grey;"&gt;((&lt;/span&gt;non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NOT&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&lt;span style="color: grey;"&gt;(&lt;/span&gt;tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;&amp;lt;&amp;gt;&lt;/span&gt; non&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag]&lt;span style="color: grey;"&gt;))&lt;/span&gt; &lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;/**&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * STEP 5&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Capture information for use by OLAP views during dimension processing.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;=&lt;/span&gt; @StepNbr &lt;span style="color: grey;"&gt;+&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;INSERT&lt;/span&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range] &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: grey;"&gt;(&lt;/span&gt; [olap_dimension_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [dimension_key_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[dimension_key_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [attribute_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[attribute_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [min_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [new_data_flag]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [process_flag]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;[created_date]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [created_by] &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "olap_dimension_id"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_schema]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;-- In the case of ProcessAdd, set the Min Key value appropriately else it must be the AbsoluteMinKeyValue.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CASE&lt;/span&gt; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_add_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;-- Note that the prev min key value was bumped by the update statement in the prior step so we can just carry this forward.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: magenta;"&gt;COALESCE&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[new_min_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; @AbsoluteMinKeyValue&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@AbsoluteMinKeyValue&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "min_key_value"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;CASE&lt;/span&gt; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: magenta;"&gt;ISNULL&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; @AbsoluteMaxKeyValue&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;&amp;gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;COALESCE&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[new_min_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; @AbsoluteMinKeyValue&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;END &lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;AS&lt;/span&gt; "new_data_flag" &lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "process_flag"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: magenta;"&gt;GETDATE&lt;/span&gt;&lt;span style="color: grey;"&gt;()&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: blue;"&gt;AS&lt;/span&gt; "created_date"&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: magenta;"&gt;ORIGINAL_LOGIN&lt;/span&gt;&lt;span style="color: grey;"&gt;()&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; "created_by"&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [#foreign_key_tree] tmp &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;LEFT&lt;/span&gt; &lt;span style="color: grey;"&gt;OUTER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range] tgt&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[olap_dimension_id] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[base_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_key_table_name] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_schema] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp&lt;span style="color: grey;"&gt;.&lt;/span&gt;[referenced_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[attribute_table_name] &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; tgt&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range_key] &lt;span style="color: grey;"&gt;IS&lt;/span&gt; &lt;span style="color: grey;"&gt;NULL;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt; &lt;span style="color: blue;"&gt;TRY&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;BEGIN&lt;/span&gt; &lt;span style="color: blue;"&gt;CATCH&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrCode &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ERR_GENERAL&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;=&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;'raised error ('&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;CAST&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;ERROR_NUMBER&lt;/span&gt;&lt;span style="color: grey;"&gt;()&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;') in step number ('&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;CAST&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;@StepNbr &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;') at line number ('&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;CAST&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;ERROR_LINE&lt;/span&gt;&lt;span style="color: grey;"&gt;()&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: blue;"&gt;NVARCHAR&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; N&lt;span style="color: red;"&gt;') with message: '&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: magenta;"&gt;ERROR_MESSAGE&lt;/span&gt;&lt;span style="color: grey;"&gt;();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;GOTO&lt;/span&gt; FAIL&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;END&lt;/span&gt; &lt;span style="color: blue;"&gt;CATCH&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;GOTO&lt;/span&gt; SUCCESS&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;FAIL&lt;span style="color: grey;"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: green;"&gt;-- Cater for max exception string length.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SET&lt;/span&gt; @ErrMsg &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;CASE&lt;/span&gt; &lt;span style="color: blue;"&gt;WHEN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: magenta;"&gt;LEN&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;@ErrMsg&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;&amp;gt;&lt;/span&gt; 2044&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;THEN&lt;/span&gt; N&lt;span style="color: red;"&gt;'...'&lt;/span&gt; &lt;span style="color: grey;"&gt;+&lt;/span&gt; &lt;span style="color: grey;"&gt;RIGHT(&lt;/span&gt;@ErrMsg&lt;span style="color: grey;"&gt;,&lt;/span&gt; 2041&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;ELSE&lt;/span&gt; &lt;span style="color: grey;"&gt;RIGHT(&lt;/span&gt;@ErrMsg&lt;span style="color: grey;"&gt;,&lt;/span&gt; 2044&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;RAISERROR&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;@ErrMsg&lt;span style="color: grey;"&gt;,&lt;/span&gt; 16&lt;span style="color: grey;"&gt;,&lt;/span&gt; 1&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;RETURN&lt;/span&gt; @ErrCode&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SUCCESS&lt;span style="color: grey;"&gt;:&lt;/span&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;RETURN&lt;/span&gt; 0&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;Step 6&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Create a user defined table function that accepts a dimension name, schema name and table name and returns the minimum and maximum values from the table created in point 2 above for a given dimension, schema and table.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ANSI_NULLS&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;QUOTED_IDENTIFIER&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.objects&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[udf_attribute_keys_for_process_add]'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [type] &lt;span style="color: grey;"&gt;IN&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'FN'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; N&lt;span style="color: red;"&gt;'IF'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; N&lt;span style="color: red;"&gt;'TF'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; N&lt;span style="color: red;"&gt;'FS'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt; N&lt;span style="color: red;"&gt;'FT'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; &lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;FUNCTION&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[udf_attribute_keys_for_process_add]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;FUNCTION&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[udf_attribute_keys_for_process_add] &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;@i_OlapDimensionID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@i_DimensionTableSchema&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @i_DimensionTableName&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @i_AttributeTableSchema&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@i_AttributeTableName&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;SYSNAME &lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;RETURNS&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;AS&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;/*&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* Returns the minimum and maximum keys for a given dimension's attribute&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* table that need to be processed by Analysis Services.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* Input Parameters:&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* ----------------&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* @i_OlapDimensionID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The Analysis Services identifier for the dimension&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for which attribute key ranges are required.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* @i_DimensionTableSchema&amp;nbsp; The schema for the table that contains the key&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attribute for the dimension.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* @i_DimensionTableName&amp;nbsp;&amp;nbsp;&amp;nbsp; The name of the table that contains the key&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; attribute for the dimension.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* @i_AttributeTableSchema&amp;nbsp; The schema for the table for the attribute to be&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;processed.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* @i_AttributeTableName&amp;nbsp;&amp;nbsp;&amp;nbsp; The name of the table for the attribute to be&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; processed.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* Ver&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Author&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Comments&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;* ---&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -------------------&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----------&amp;nbsp; ---------------------------------&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Philip Stephenson&amp;nbsp;&amp;nbsp; 01-Jul-2011&amp;nbsp; Original version.&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: green; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: green;"&gt;-- Return results.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;RETURN&lt;/span&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; [min_key_value]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [max_key_value]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [olap_dimension_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @i_OlapDimensionID &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_key_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @i_DimensionTableSchema &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [dimension_key_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @i_DimensionTableName &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [attribute_table_schema] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @i_AttributeTableSchema &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [attribute_table_name] &lt;span style="color: grey;"&gt;=&lt;/span&gt; @i_AttributeTableName &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [process_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1 &lt;span style="color: grey;"&gt;AND&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [new_data_flag] &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;Step 7&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Update the current views used to present data to Analysis Services to join to the function created in point 6 above, limiting the output to be where the surrogate key value is between the minimum and maximum values.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;ANSI_NULLS&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;SET&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;QUOTED_IDENTIFIER&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;IF&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: grey;"&gt;EXISTS&lt;/span&gt; &lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys.views&lt;/span&gt; &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; [object_id] &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: magenta;"&gt;OBJECT_ID&lt;/span&gt;&lt;span style="color: grey;"&gt;(&lt;/span&gt;N&lt;span style="color: red;"&gt;'[dbo].[v_process_add_customer]'&lt;/span&gt;&lt;span style="color: grey;"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;BEGIN&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;DROP&lt;/span&gt; &lt;span style="color: blue;"&gt;VIEW&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[v_process_add_customer]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;END&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-size: xx-small;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;CREATE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt; &lt;span style="color: blue;"&gt;VIEW&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[v_process_add_customer]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;AS&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; [customer_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [address_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [customer_group_id]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer] att &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;INNER&lt;/span&gt; &lt;span style="color: grey;"&gt;JOIN&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[udf_attribute_keys_for_process_add]&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'Customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color: red;"&gt;'customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&lt;span style="color: grey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&lt;span style="color: grey;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: red;"&gt;'customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;)&lt;/span&gt; prc&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; att&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer_id] &lt;span style="color: grey;"&gt;BETWEEN&lt;/span&gt; prc&lt;span style="color: grey;"&gt;.&lt;/span&gt;[min_key_value] &lt;span style="color: grey;"&gt;AND&lt;/span&gt; prc&lt;span style="color: grey;"&gt;.&lt;/span&gt;[max_key_value]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: xx-small;"&gt;GO&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-size: 14pt;"&gt;Test Drive&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Now that we have everything setup, let’s give it a whirl. First of all we need to identify all of the relationships for a given dimension, customer in this case, starting from the key table.&lt;/div&gt;&lt;div align="right" class="MsoNormal" style="text-align: right;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;EXECUTE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[usp_reseed_dimension_table_relationship_by_dimension]&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp; @i_DimensionID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;=&lt;/span&gt; 1&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp; @i_DimensionKeyTableSchema &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp; @i_DimensionKeyTableName&amp;nbsp;&amp;nbsp; &lt;span style="color: grey;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;We can see what this did be executing the following:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;SELECT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_table_relationship]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Next we need to identify the minimum and maximum surrogate key values in each of the tables, which we do as follows:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;EXECUTE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[usp_derive_new_attribute_keys_for_processing]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;We can see what this did by executing the following:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;SELECT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;All we need to do now is select from the view to see all &lt;i style="mso-bidi-font-style: normal;"&gt;new&lt;/i&gt; entries:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;SELECT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;FROM&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[v_process_add_customer]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;To see how this works, we can select from the function we created earlier as follows:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;SELECT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;FROM&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[udf_attribute_keys_for_process_add]&lt;span style="color: grey;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'Customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;'customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;'dbo'&lt;/span&gt;&lt;span style="color: grey;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;'customer'&lt;/span&gt;&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="font-size: 8pt;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;To actually test the concept of “process add”, let’s now add a new member:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;INSERT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[customer] &lt;span style="color: grey;"&gt;(&lt;/span&gt;[customer_name]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [address_id]&lt;span style="color: grey;"&gt;,&lt;/span&gt; [customer_group_id]&lt;span style="color: grey;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;VALUES&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;(&lt;/span&gt;&lt;span lang="EN-US" style="color: red; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;'Customer 4'&lt;/span&gt;&lt;span lang="EN-US" style="color: grey; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;,&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; 2&lt;span style="color: grey;"&gt;,&lt;/span&gt; 2&lt;span style="color: grey;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;In order to capture the metadata around new key values etc. we need to execute:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;EXECUTE&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[usp_derive_new_attribute_keys_for_processing]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Which, once again, has captured the metadata as follows:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;SELECT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;To see what Analysis Services would see, run the following:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="mso-layout-grid-align: none; mso-pagination: none; text-autospace: none;"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;SELECT&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; &lt;span style="color: grey;"&gt;*&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US" style="color: blue; font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;FROM&lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt; [dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[v_process_add_customer]&lt;span style="color: grey;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-size: 14pt;"&gt;Conclusion&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;Now I will admit that I haven’t fully test driven all of this myself to see if it all works in all situations etc. so please let me know if anything is broken and I’ll aim to fix it. Either way I hope the concept is clear, such that you can make any modifications as required.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Hopefully you will have noted that in the stored procedure that determines the min and max key values, that it can be easily updated to accommodate ProcessUpdate and ProcessAdd situations by not hard-coding the value for the “process_add_flag” but I’ll leave that as an exercise for the reader.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style="font-family: Cambria; font-size: 12pt;"&gt;From the above code and sample, the thing to note is that immediately before processing dimensions the &lt;/span&gt;&lt;span lang="EN-US" style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;[dbo]&lt;span style="color: grey;"&gt;.&lt;/span&gt;[dimension_process_attribute_key_range]&lt;/span&gt;&lt;span style="font-family: Cambria; font-size: 12pt;"&gt; stored procedure must be called in order to “snapshot” all surrogate key values. Clearly you need to be careful not to get out of sync else things will not work. If that happens you will need to revert back to a “ProcessUpdate” and then continue as per normal.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-3080597188313824647?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/X7H98nbuKOQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/3080597188313824647/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2011/07/implementing-analysis-services-process.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/3080597188313824647?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/3080597188313824647?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/X7H98nbuKOQ/implementing-analysis-services-process.html" title="Implementing Analysis Services Process Add Functionality – Part 3" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>0</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2011/07/implementing-analysis-services-process.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QGQXY7cCp7ImA9WhZWF0U.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-4401074533460739158</id><published>2011-05-19T08:15:00.000+01:00</published><updated>2011-05-19T08:15:20.808+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-19T08:15:20.808+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Analysis Services" /><title>Implementing Analysis Services Process Add Functionality – Part 2</title><content type="html">&lt;style&gt;
@font-face {
  font-family: "Cambria";
}p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman"; }div.Section1 { page: Section1; }
&lt;/style&gt;     &lt;br /&gt;
&lt;div class="MsoNormal"&gt;In a previous &lt;a href="http://bi-logger.blogspot.com/2011/04/implementing-analysis-services-process.html"&gt;here&lt;/a&gt; I briefly mentioned some of the benefits and issues surrounding the implementation of incremental processing of Analysis Services dimensions. In this post I’ll go into a bit more detail with regards configuring the SQL Server schema to support incremental processing of Analysis Services dimensions.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;I should point out upfront that I am specifically referring to SQL Server as the relational database here but it could be any database really. The thing is, I’m going to use some SQL Server features as a shortcut both for performance reasons and ease of understanding. I know Oracle has similar functionality but I cannot document each and every RDBMS so I have just chosen SQL Server as the basis for this post.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;So straight off, we have a choice to make. Should we use an out-of-line DSV when incrementally processing or not? Depending on what is chosen here influences how you go about implementing incremental dimension processing, though in the solution presented here only the final steps will need to change. To get around the issue of having to configure Kerberos and submitting a potentially large DSV every time we wish to process, I have chosen not to go the out-of-line DSV route. Although there is nothing that I could see in SQL Profiler, I would presume that there is some form of overhead to Analysis Services evaluating an out-of-line DSV, no matter how trivial.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;It’s also worth mentioning that a nice side-effect of my solution is that we also overcome the race-condition with regards attribute processing when processing dimensions whilst the relational database is loading dimensional data. For example, in the case where you load a new customer linked to a new customer group and Analysis Services has already processed the customer group attribute but not the customer attribute, dimension processing will fail. &lt;span&gt;&amp;nbsp;&lt;/span&gt;The reason being that before the new member was added, Analysis Services will already have captured the set of customer group attributes as it was before the new member arrived in the table. This means that processing of the customer attribute will fail when Analysis Services tries to link the customer to the customer group, as the related member will not exist in the processed set of members for the customer group attribute. This can be extremely annoying and there is no out-of-the-box way to force a consistent snapshot of all attributes for a dimension during processing.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;b&gt;One Solution:&lt;/b&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;So, looking at snapshots, it seems that we need to roll our own. Clearly one idea is to effectively snapshot all the rows we wish to load for the dimension across every attribute. We can then present only those rows for loading by Analysis Services at process time. Using this method we can ensure that we prevent the race-condition described earlier during a ProcessUpdate operation too. The trick is how to snapshot the rows quickly and cheaply. (i.e. We don’t want to have to copy an entire table or perform a join across the current dimension table and a previous snapshot if we can avoid it.)&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;So, in my proposed solution, we first of all need to ensure that every attribute that is to be loaded into the dimension is recorded in its own table. That is, the relational schema for the dimension needs to be snow flaked. I know Kimball die-hard fans will be screaming around about now but I haven’t said that you can’t also have a star-schema table. For large Analysis Services dimensions this is usually what I do. I ensure that I generate integer surrogate keys for every attribute using snow-flaked tables with identity columns and configure the Analysis Services DSV using those tables such that only a table scan of a small table is required for every attribute. However, I &lt;i&gt;also&lt;/i&gt; ensure that the “key” table (or bottom level) of the dimension is a star-schema table for relational reporting and as such also contains the attributes from related tables.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;For example, given a customer dimension with customer as the bottom level and being related to group and organisation, I would create an organisation table and a customer group table to capture the discrete entities and generate a surrogate key for each. The customer table however, will be a star schema table, generating a surrogate key for each customer but also containing the attributes of the related groups and organisations.)&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-QtMnHcClKq4/TdTCMPGScGI/AAAAAAAAACg/0tbxTQ_z8tY/s1600/CustomerRelationship.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="183" src="http://4.bp.blogspot.com/-QtMnHcClKq4/TdTCMPGScGI/AAAAAAAAACg/0tbxTQ_z8tY/s400/CustomerRelationship.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Customer Relationships&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;The main “trick” here, is to ensure that &lt;i&gt;every&lt;/i&gt; snow-flaked table for each attribute uses an identity column for its surrogate key. You should also endeavour to choose an integer that best matches the expected maximum number of entries, be it a smallint (2 byte signed integer), int (4 byte signed integer) or bigint (8 byte signed integer). Analysis Services is no longer partial to the tinyint data type so best steer clear of that though.&lt;/div&gt;&lt;div class="MsoNormal"&gt;           &lt;style&gt;
@font-face {
  font-family: "Cambria";
}p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman"; }p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph { margin: 0cm 0cm 0.0001pt 36pt; font-size: 12pt; font-family: "Times New Roman"; }p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst { margin: 0cm 0cm 0.0001pt 36pt; font-size: 12pt; font-family: "Times New Roman"; }p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle { margin: 0cm 0cm 0.0001pt 36pt; font-size: 12pt; font-family: "Times New Roman"; }p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast { margin: 0cm 0cm 0.0001pt 36pt; font-size: 12pt; font-family: "Times New Roman"; }div.Section1 { page: Section1; }ol { margin-bottom: 0cm; }ul { margin-bottom: 0cm; }
&lt;/style&gt;       &lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;This next part isn’t really required, though it will make your life easier in the long run as well as being good practice. Make sure that you have foreign keys setup between all of the snow flaked tables including the star-schema table and the snow-flaked tables. Essentially “document” the relationship between all related attributes by means of foreign keys. The reason for this will become clear later.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;So we now have our dimension configured such that we have integer surrogate keys for every attribute in our dimension and we have both star-schema and snow-flaked tables. We could go ahead and build an Analysis Services dimension from this right now, if we so wished, so we can consider the schema requirements component of the solution to be complete.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Now that we have our dimension schema I’ll attempt to explain how all of this is used. In part 3 I’ll present some actual code that can be used as a basis for a more substantial implementation but for now I’ll just present a conceptual implementation plan. So, here goes…&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18pt;"&gt;&lt;span&gt;&lt;span&gt;1.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;First we need to capture the list of dimensions we are interested in and the associated key table for that dimension. Note that by “key table”, I’m referring to the table that contains the attribute to be used as the key in the dimension. Create a table that captures this information.&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18pt;"&gt;&lt;span&gt;&lt;span&gt;2.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Next we need to create a table in which we will capture the names of all the tables used by a given dimension on rows (i.e. the key table and all related tables) as well as the previous and current identity values for each table.&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18pt;"&gt;&lt;span&gt;&lt;span&gt;3.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;Populate the table created in point 1 above with the dimensions for which you wish to use process add and where the underlying relational schema has been configured as described in the main text.&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18pt;"&gt;&lt;span&gt;&lt;span&gt;4.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Create a stored procedure that accepts a given dimension name and key table name and, using the information schema views etc, identify all related tables by means of foreign key relationships. Using this information, populate the table created in point 2 above with an arbitrary minimum value and, using the IDENT_CURRENT(‘&lt;table_name&gt;’) function, populate the max value with the current identity value for the table. Note that you must ensure that you retrieve the values for the key table &lt;i&gt;before&lt;/i&gt; any of the related tables. This is what provides protection against the race condition discussed earlier.&lt;br /&gt;
If you did not create foreign keys between all tables, you will need statically capture all tables used by a given dimension and maintain this over time as tables are added or dropped.&lt;/table_name&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18pt;"&gt;&lt;span&gt;&lt;span&gt;5.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Create another stored procedure that iterates through each entry in the table created in point 1 above and calls the stored procedure created in point 4 above.&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18pt;"&gt;&lt;span&gt;&lt;span&gt;6.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Create a user defined table function that accepts a dimension name, schema name and table name and returns the minimum and maximum values from the table created in point 2 above for a given dimension, schema and table.&lt;/div&gt;&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18pt;"&gt;&lt;span&gt;&lt;span&gt;7.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Update the current views used to present data to Analysis Services to join to the function created in point 6 above, limiting the output to be where the surrogate key value is between the minimum and maximum values.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;And that’s it really, or the basic nuances of it anyway. Clearly, in point 4 above, there is some work required to only set an arbitrary minimum value the first time the table is populated and thereafter to set the minimum value to the previous maximum value + 1. Where the minimum value is greater than the maximum value you get an indication that now rows have been added to the table since it was processed.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;The final step in the solution of course, is to ensure that the stored procedure created in step 5 is always called before Analysis Services processing commences. In order to perform a full process of the database from SSMS say, you just need to reset the table created in point 2. (eg. Truncate the table and reseed with arbitrary minimum value and current identity value.)&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;And there you go, easy-peasy eh? &lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style="font-family: Cambria; font-size: 12pt;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-4401074533460739158?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/e77EBqoVBsg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/4401074533460739158/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2011/05/implementing-analysis-services-process.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/4401074533460739158?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/4401074533460739158?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/e77EBqoVBsg/implementing-analysis-services-process.html" title="Implementing Analysis Services Process Add Functionality – Part 2" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-QtMnHcClKq4/TdTCMPGScGI/AAAAAAAAACg/0tbxTQ_z8tY/s72-c/CustomerRelationship.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2011/05/implementing-analysis-services-process.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8ERns5eyp7ImA9WhZVEUU.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-9105291315467793660</id><published>2011-04-26T23:16:00.001+01:00</published><updated>2011-05-23T21:50:07.523+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-23T21:50:07.523+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Analysis Services" /><category scheme="http://www.blogger.com/atom/ns#" term="ProcessAdd" /><title>Implementing Analysis Services Process Add Functionality – Part 1</title><content type="html">&lt;style&gt;
@font-face {
  font-family: "Cambria";
}p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman"; }a:link, span.MsoHyperlink { color: blue; text-decoration: underline; }a:visited, span.MsoHyperlinkFollowed { color: purple; text-decoration: underline; }pre { margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: Courier; }p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph { margin: 0cm 0cm 0.0001pt 36pt; font-size: 12pt; font-family: "Times New Roman"; }p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst { margin: 0cm 0cm 0.0001pt 36pt; font-size: 12pt; font-family: "Times New Roman"; }p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle { margin: 0cm 0cm 0.0001pt 36pt; font-size: 12pt; font-family: "Times New Roman"; }p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast { margin: 0cm 0cm 0.0001pt 36pt; font-size: 12pt; font-family: "Times New Roman"; }span.HTMLPreformattedChar { font-family: Courier; }span.moz-txt-citetags {  }div.Section1 { page: Section1; }ol { margin-bottom: 0cm; }ul { margin-bottom: 0cm; }
&lt;/style&gt;     &lt;br /&gt;
&lt;div class="MsoNormal"&gt;I think most people who have used Analysis Services know about the ability to incrementally process dimensions using “ProcessAdd” and let’s face it, without the ability to partition dimensions it’s about the only data-reducing optimisation we can perform on dimensions. Sure, we have “by table” processing versus “by attribute” processing, the ability to process attributes in parallel and we can make sure that the relational layer can produce results quickly by either using snow-flaked tables or star-schema tables with indexes etc. However, we are still bound by the amount of time taken to process a given set of rows, where a subset of this information may already have been previously processed.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;To this end we can use incremental dimension processing, i.e. the “ProcessAdd” processing type, which aims to reduce the amount of time taken to process a dimension by only processing new information into the dimension. Clearly changes in hierarchy relationships will still require “ProcessUpdate” or “ProcessFull” as the entire dimension data set will need to be reprocessed in order to identify and reflect any hierarchy changes.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;However there are some fundamental limitations with regards how fast incremental dimension processing can go…&lt;/div&gt;&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18pt;"&gt;1.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Analysis Services performs transactional processing using files on the file system. As such, when starting a transaction its first task is to take a copy of all relevant files. It then starts to perform processing and if processing is successful the newly processed file is used. Based on this we can see that the amount of time taken to process must include at least the amount of time taken to clone all relevant files for the dimension. This can be a non-trivial amount of time on large dimensions.&lt;br /&gt;
&lt;i&gt;I guess an enhancement request could be to have Analysis Services clone existing dimension files using a background thread some time after processing. A per dimension configuration would be ideal so that we don’t automatically double disk space and waste resources on small dimensions.&lt;/i&gt;&lt;/div&gt;&lt;div class="MsoListParagraphCxSpMiddle" style="text-indent: -18pt;"&gt;2.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;In order to use incremental processing on dimensions there appears to be two general forms of implementation. There’s the method that presents only the new rows to Analysis Services during processing (the intended but clearly more arduous method) and the one that presents all rows but changes the error configuration to ignore duplicate errors. I consider the latter option a bit of a hack to be honest and not in the true spirit of incremental processing.&lt;/div&gt;&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18pt;"&gt;3.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Even after providing only new rows, Analysis Services needs to ensure that attributes which have ordering defined based on some other attribute are updated to reflect this. Clearly, if ordering has been defined on an attribute with many members, the act of Analysis Services revisiting this set could take a considerable amount of time. &lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;From what I’ve seen, the implementation of Analysis Services “ProcessAdd” on dimensions seems somewhat diverse and I’m not aware of anyone documenting a definitive guide to implementing this. Now I certainly don’t intend these posts to be considered a definitive guide but more of a starting point for discussion. To this end, I’ll try to cover off how I see “ProcessAdd” working with regards the relationship between Analysis Services and SQL Server. Don’t get me wrong, others have most definitely blogged about “ProcessAdd” and you can see Greg Galloway’s blog for more information on ProcessAdd performance metrics here: &lt;a href="http://www.artisconsulting.com/blogs/greggalloway/Lists/Posts/Post.aspx?List=83c71d76-a4d8-4197-9257-38d6b857634f&amp;amp;ID=7"&gt;http://www.artisconsulting.com/blogs/greggalloway/Lists/Posts/Post.aspx?List=83c71d76-a4d8-4197-9257-38d6b857634f&amp;amp;ID=7&lt;/a&gt;. There are others out there like this too. However, these posts tend to focus more on the Analysis Services side, detailing the performance characteristics or the options available such as Out-of-Line DSV’s etc. but not much with regards how to actually go about integrating the relational layer and Analysis Services with incremental processing of dimensions in mind.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;So what are the challenges with integrating Analysis Services with SQL Server?&lt;/div&gt;&lt;div class="MsoListParagraphCxSpFirst" style="text-indent: -18pt;"&gt;1.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Well, first we need to be able to &lt;i&gt;identify&lt;/i&gt; new rows for &lt;i&gt;every&lt;/i&gt; attribute. Note that it is insufficient to only identify new “key” rows as each attribute in a dimension is processed separately. So it is well possible, and indeed likely, that any new “key” row will be related to attribute members that have already been processed.&lt;/div&gt;&lt;div class="MsoListParagraphCxSpLast" style="text-indent: -18pt;"&gt;2.&lt;span style="font: 7pt &amp;quot;Times New Roman&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Once we have the ability to identify new rows for every attribute, how do we only present these new rows to Analysis Services when processing the dimension? &lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Delving into the second point a bit more, we should note that this tends to be a bit of a double-edged sword. We could use an out-of-line DSV to point Analysis Services to some object(s) to present only new rows but the use of an out-of-line DSV requires a connection to be specified too. Now as soon as you specify a connection in an XMLA script you lose the option to allow Analysis Services to process under the service account. So you either have to specify a username/password combination in the XMLA connection configuration, not nice, or use Kerberos and ensure that the account submitting the process request has sufficient privileges both in Analysis Services and in SQL Server. We could also opt to just configure the base objects upon which the dimension is built to only present new rows, allowing the use of the service account during processing. However, if you do this then how do you go about performing a “ProcessUpdate” or “ProcessFull” on an adhoc basis in order to fix a rigid relationship issue or to refresh the hierarchies?&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style="font: 12pt &amp;quot;Times New Roman&amp;quot;;"&gt;In my next post (&lt;a href="http://bi-logger.blogspot.com/2011/05/implementing-analysis-services-process.html"&gt;here&lt;/a&gt;) I’ll try to cover off one solution to this problem. Clearly this is not going to be straightforward or risk-free but hopefully it’s a starting point.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-9105291315467793660?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/yO4E_L_fZJ4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/9105291315467793660/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2011/04/implementing-analysis-services-process.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/9105291315467793660?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/9105291315467793660?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/yO4E_L_fZJ4/implementing-analysis-services-process.html" title="Implementing Analysis Services Process Add Functionality – Part 1" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>0</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2011/04/implementing-analysis-services-process.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMFSXY_cSp7ImA9WhZQEEo.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-7211725785085475197</id><published>2011-04-17T22:34:00.002+01:00</published><updated>2011-04-17T22:40:18.849+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-17T22:40:18.849+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="&quot;SQL Server&quot;" /><category scheme="http://www.blogger.com/atom/ns#" term="&quot;Reporting Services&quot;" /><title>Configure Reporting Services Database on a SQL Server with non-default port</title><content type="html">&lt;style&gt;
@font-face {
  font-family: "Courier New";
}@font-face {
  font-family: "Cambria";
}p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman"; }a:link, span.MsoHyperlink { color: blue; text-decoration: underline; }a:visited, span.MsoHyperlinkFollowed { color: purple; text-decoration: underline; }div.Section1 { page: Section1; }
&lt;/style&gt;     &lt;br /&gt;
&lt;div class="MsoNormal"&gt;I know this is “so last year” when talking about SQL Server 2008 Reporting Services R1 but I figured I’d talk about it anyway, as it may apply to R2 as well. I haven’t checked so please feel free to leave a comment if you can confirm one way or the other.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;I am also aware that it has been a long time since we discovered this problem and that there is now another more elegant solution to the problem as well. However, I figured I would provide the information on how we solved this same issue for reference.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;So, given a SQL Server instance where the SQL Browser service is disabled (or cannot be reached) and/or SQL Server is using a non-default port number, when attempting to generate the “rights” script whilst configuring Reporting Services you get the following error: &lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;System.Net.Sockets.SocketException: No such host is known&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Net.Dns.GetAddrInfo(String name)&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Net.Dns.GetHostEntry(String hostNameOrAddress)&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at ReportServicesConfigUI.RSDatabase.IsLocalDbServer(String dbServer)&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at ReportServicesConfigUI.RSDatabase.GrantRSConnectionRights()&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at ReportServicesConfigUI.RSDatabase.CreateNewDatabase()&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;; font-size: 8pt;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;In our case, our UAT environment has the SQL Browser service disabled and we do not use the default port for SQL Server, both for security reasons I suspect. As such we need to specify our SQL Server as “&lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt;servername.domain,port&lt;/span&gt;” which in the general case is fine. Even when creating the actual databases whilst configuring Reporting Services this is fine. However, it would appear that when generating the rights script, this form of connection string is not parsed into the individual server name and port number components. Really bizarre when one part of the product does and the other does not, especially when it is in the same part of the configuration!&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;For further confirmation that the connection string is not parsed, see:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/b/psssql/archive/2009/03/05/socketexception-when-creating-a-new-report-server-database.aspx"&gt;http://blogs.msdn.com/b/psssql/archive/2009/03/05/socketexception-when-creating-a-new-report-server-database.aspx&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;So after much Googling at the time, we discovered the link above, as well as the following one, which at the time did &lt;i&gt;not&lt;/i&gt; include a solution.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/b/sameersurve/archive/2009/06/15/no-such-host-is-known-error-when-configuring-ssrs-2008.aspx"&gt;http://blogs.msdn.com/b/sameersurve/archive/2009/06/15/no-such-host-is-known-error-when-configuring-ssrs-2008.aspx&lt;/a&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;However, from both of those links we did get enough information in order to determine what we needed to do. Still, I’m not sure why specifying the instance name as well as the port number works (as detailed in the second of those links) over just the port number as that’s a bit weird, but if it works, hey why not use it. &lt;i&gt;Note: I haven’t tested that the instance name and port number does actually work.&lt;/i&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;In our case though, we went with the *nix philosophy that you can always do more with the command line tools than you can with the GUI. So we did that. Essentially we used the GUI to configure Reporting Services as far as it would let us, including setting up the databases and allowing it to fail when it tried to configure the “rights scripts”. We then switched to using the command line tools by connecting as the relevant user and then ran the following:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;rsconfig -c -m &lt;rs_server_name&gt; &amp;lt;SERVER_NAME&amp;gt; -s &amp;lt;DATABASE_NAME,PORT&amp;gt;&amp;nbsp;&lt;database_name,port&gt; -d reportserver -a Windows&lt;/database_name,port&gt;&lt;/rs_server_name&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;style&gt;
@font-face {
  font-family: "Cambria";
}p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman"; }div.Section1 { page: Section1; } 
&lt;/style&gt;           &lt;style&gt;
@font-face {
  font-family: "Cambria";
}p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman"; }div.Section1 { page: Section1; }
&lt;/style&gt;   &lt;span style="font-family: inherit; font-size: 12pt;"&gt;Where &amp;lt;RS_SERVER_NAME&amp;gt; is the server name for the Reporting Services server and &amp;lt;DATABASE_NAME,PORT&amp;gt; is the database name and port number for the SQL Server where we were trying&lt;span&gt; &lt;/span&gt;to install the RS databases.&lt;/span&gt;  &lt;rs_server_name&gt;&lt;database_name,port&gt;&lt;/database_name,port&gt;&lt;/rs_server_name&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;After running the command, we restarted Reporting Services, went back into the configuration tool to apply the changes there and continued.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style="font-family: Cambria; font-size: 12pt;"&gt;Clearly this is a bit of a hack, at best, and most likely not supported but in our case it worked and we were up and running after a couple of hours of head scratching and bemoaning the insanity that is Reporting Services.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-7211725785085475197?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/Ab2smoEBeI0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/7211725785085475197/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2011/04/configure-reporting-services-database.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/7211725785085475197?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/7211725785085475197?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/Ab2smoEBeI0/configure-reporting-services-database.html" title="Configure Reporting Services Database on a SQL Server with non-default port" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>1</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2011/04/configure-reporting-services-database.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0IFSHc6cCp7ImA9WhZRF08.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-6639494302323877915</id><published>2011-04-13T21:11:00.000+01:00</published><updated>2011-04-13T21:11:59.918+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-13T21:11:59.918+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="&quot;SQL Server&quot;" /><category scheme="http://www.blogger.com/atom/ns#" term="T-SQL" /><title>SQL Server - PARSENAME Function</title><content type="html">&lt;style&gt;
@font-face {
  font-family: "Courier New";
}@font-face {
  font-family: "Wingdings";
}@font-face {
  font-family: "Cambria";
}p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; font-size: 12pt; font-family: "Times New Roman"; }div.Section1 { page: Section1; }
&lt;/style&gt;     &lt;br /&gt;
&lt;div class="MsoNormal"&gt;Similar to the QUOTENAME function, another one of those often unknown or overlooked functions is the PARSENAME function. I’ll confess that I’m not entirely sure why it isn’t PARSE_NAME, inline with other functions such as OBJECT_NAME etc. but then I guess the string functions all seem to be concatenated. Anyhoo, let’s ignore all of that for now.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;The beauty of this function is that it allows you to get the individual components of a given 4-part object name presented as a string. So, given &lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt;'[ServerNameFoo].[DatabaseBar].[SchemaBaz].[ObjectCaz]&lt;/span&gt;' we can get the server name component or the database component if we want, maybe to ensure that what we are evaluating exists in the current database for example. We can also get the schema or object names too. I agree that its usefulness is probably limited to esoteric edge cases but it is one of those functions that when you need it, it’s really handy. Especially when you consider trying to implement this functionality yourself and catering for object names with or without square brackets or full stops etc. in their name.&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;To use the function you would write something like:&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span style="color: #000090; font-family: &amp;quot;Courier New&amp;quot;;"&gt;SELECT&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;;"&gt; &lt;span style="color: #ff66ff;"&gt;PARSENAME&lt;/span&gt;&lt;span style="color: #595959;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'server.database.schema.object'&lt;/span&gt;, 2&lt;span style="color: #595959;"&gt;);&lt;/span&gt;&lt;/span&gt; &lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;This would return the value “schema”. Note that the function doesn’t evaluate whether or not the object exists and doesn’t care. All it does is return the requested component of the string if it is available else NULL. For an example of it in use, have a look at the internals of the &lt;span style="color: #943634; font-family: &amp;quot;Courier New&amp;quot;;"&gt;sp_spaceused&lt;/span&gt; stored procedure. (i.e. Execute &lt;span style="color: #943634; font-family: &amp;quot;Courier New&amp;quot;;"&gt;sp_helptext &lt;/span&gt;&lt;span style="color: red; font-family: &amp;quot;Courier New&amp;quot;;"&gt;'sp_spaceused'&lt;/span&gt;.)&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;Also note that there are some articles on the web about using this function in order to split strings for other reasons (eg. IP Addresses) which could be quite a neat solution. (See: &lt;a href="http://www.sqlteam.com/article/using-the-parsename-function-to-split-delimited-data"&gt;http://www.sqlteam.com/article/using-the-parsename-function-to-split-delimited-data&lt;/a&gt;) However, remember that the function is SQL Server delimiter aware so you need to be careful. Running the function on the string 'foo.[bar]'&amp;nbsp; to return the object name component will return "bar" and not "[bar]".&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal"&gt;I’ll be honest and say that I’ve never really had a reason to use it but at least I know it’s there if I do. And now you do too. &lt;span style="font-family: Wingdings;"&gt;&lt;span&gt;:-)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-6639494302323877915?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/5rDimnAIvWI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/6639494302323877915/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2011/04/sql-server-parsename-function.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/6639494302323877915?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/6639494302323877915?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/5rDimnAIvWI/sql-server-parsename-function.html" title="SQL Server - PARSENAME Function" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>0</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2011/04/sql-server-parsename-function.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMFQXs8cSp7ImA9Wx9bE0s.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-5305975353867990513</id><published>2011-02-22T08:31:00.003Z</published><updated>2011-02-22T08:46:50.579Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-22T08:46:50.579Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Analysis Services" /><title>Analysis Services Slicing</title><content type="html">I must admit that I never cease to be amazed how you can work with a product for years and still every now and again a little nugget appears that makes you go "Really? Does it &lt;i&gt;really&lt;/i&gt; work like that?"&lt;br /&gt;
&lt;br /&gt;
I had one of those moments recently whilst answering posts on the Analysis Services forum regarding why one query hit only one partition whilst another query hit all the partitions in a measure group. You can read about all of this here:&amp;nbsp;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre-wrap;"&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/b4b4f28a-2ddd-4335-91eb-1732b371eb74"&gt;http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/b4b4f28a-2ddd-4335-91eb-1732b371eb74&lt;/a&gt;&lt;/span&gt;&amp;nbsp;where Greg Galloway provides some excellent insight into all of this.&lt;br /&gt;
&lt;br /&gt;
So, for the most part people know about partitioning in Analysis Services and if not, someone at some point on the forums will mention that "you really should be partitioning your data" etc. This eventually evolves into "oh yes and if you are partitioning you should be setting the slice as well" then queue many links to various articles on slicing etc. and the world is good. Or is it...&lt;br /&gt;
&lt;br /&gt;
I will admit that I have been one of those citizens posting about the virtues of partitioning and slicing whilst apparently being blissfully (and dangerously) ignorant of the real mechanics of slicing. As far as I can tell, all Microsoft documentation appears to indicate that "ProcessIndexes" is required for aggregations but nowhere does it state that it is required for slicing too. For those of you that are now going "huh, you what?", yessssssss, welcome to my world. Note too, how I am deliberately ignoring the debate regarding whether or not one should manually set the slice instead of relying on auto-slicing, as funnily enough manual slicing is affected too, albeit in a different way.&lt;br /&gt;
&lt;br /&gt;
Essentially it boils down to this. If you are relying on auto-slicing (either by design or merely for those attributes where it may just happen to only contain a small subset of members) then you need to guarantee that you call "ProcessIndexes" (which is naturally "called" automatically when using "ProcessFull") else auto-slicing will not take place. Yup, that's the fundamental point here. Auto-slicing, or at least the capturing of the min and max data IDs for an attribute, does &lt;i&gt;not&lt;/i&gt; happen whilst processing the data into the partition but rather during the processing of indexes. Similarly, if you set the slice on a partition, unless you call "ProcessIndexes" on the partition, the data it contains will not be validated against the slice and thus you can actually process incorrect data into a partition.&lt;br /&gt;
&lt;br /&gt;
I guess this makes sense from a programming perspective, in that tracking every value whilst processing data &amp;nbsp;into the partition would make the act of processing more expensive. However, when processing indexes this is essentially what this part of processing is doing anyway I would suspect and thus it makes sense to happen here. Note that due to this, slicing is also governed by the IndexBuildThreshold property too. The problem is, other than this link&amp;nbsp;&lt;span class="Apple-style-span" style="color: #333333; font-family: 'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px;"&gt;&lt;a href="http://cwebbbi.wordpress.com/2007/11/08/viewing-partition-slice-information/" style="border-bottom-style: none; border-bottom-width: 0px; border-color: initial; border-color: initial; border-left-style: none; border-left-width: 0px; border-right-style: none; border-right-width: 0px; border-style: initial; border-top-style: none; border-top-width: 0px; border-width: initial; color: #0066dd; cursor: pointer; font-family: inherit; font-style: inherit; font-weight: inherit; list-style-type: none; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;" target="_blank" title="http://cwebbbi.wordpress.com/2007/11/08/viewing-partition-slice-information/"&gt;http://cwebbbi.wordpress.com/2007/11/08/viewing-partition-slice-information&lt;/a&gt;&lt;/span&gt;&amp;nbsp;I have not seen anything else that indicates that you need ProcessIndexes in order to make slicing work completely.&lt;br /&gt;
&lt;br /&gt;
Note also, that it is often stated in Microsoft performance tuning articles to use ProcessData followed by ProcessIndexes instead of the generic ProcessFull. However, once again it is usually stated that ProcessIndexes is required in order to rebuild aggregations and nowhere does it mention slicing.&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-5305975353867990513?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/_5-s32AZn_M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/5305975353867990513/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2011/02/analysis-services-slicing.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/5305975353867990513?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/5305975353867990513?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/_5-s32AZn_M/analysis-services-slicing.html" title="Analysis Services Slicing" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>0</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2011/02/analysis-services-slicing.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkACQH84eyp7ImA9WhZQGU4.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-366161042915655875</id><published>2010-10-23T10:00:00.001+01:00</published><updated>2011-04-27T19:59:21.133+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-27T19:59:21.133+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Stored Procedures" /><category scheme="http://www.blogger.com/atom/ns#" term="Best Practices" /><category scheme="http://www.blogger.com/atom/ns#" term="Analysis Services" /><category scheme="http://www.blogger.com/atom/ns#" term="ASSP" /><title>Analysis Services Stored Procedure Best Practices</title><content type="html">Whilst answering questions on the Microsoft Analysis Services forum the other day, I came across a question regarding recursive MDX. At first read I thought that an Analysis Services stored procedure might be quicker than recursive MDX, which was an incorrect assumption.&lt;br /&gt;
&lt;br /&gt;
However, in the discussion Darren Gosbell posted a list of best practices with regards Analysis Services stored procedures that I hadn't seen before, so I figured I would post them here too.&lt;br /&gt;
&lt;br /&gt;
So, the "best practices" for Analysis Services stored procedures (ASSP) are apparently as follows:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;for administrative functions &lt;/li&gt;
&lt;li&gt;for static sets, scopes, LHS of assignment and other early-binding things &lt;/li&gt;
&lt;li&gt;It is usually OK to use sprocs for query axes &lt;/li&gt;
&lt;li&gt;It is usually OK to use sprocs if they don’t need to get cell data (but only look at metadata and members) &lt;/li&gt;
&lt;li&gt;inside calculations if there is good NEB that can be defined on the calculation &lt;/li&gt;
&lt;li&gt;inside calculations without NEB if sproc is executed over small amount of cells, i.e. inside WHERE clause etc. &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
The thread where you can see all of this is here: &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/9feb1ec0-d5f4-4b8c-9d7c-0195d25d7adc"&gt;http://social.msdn.microsoft.com/Forums/en-US/sqlanalysisservices/thread/9feb1ec0-d5f4-4b8c-9d7c-0195d25d7adc&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-366161042915655875?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/4v7WgegoENk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/366161042915655875/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2010/10/analysis-services-stored-procedure-best.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/366161042915655875?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/366161042915655875?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/4v7WgegoENk/analysis-services-stored-procedure-best.html" title="Analysis Services Stored Procedure Best Practices" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>2</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2010/10/analysis-services-stored-procedure-best.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8MR3g7cSp7ImA9WxBUGE8.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-8354085012938259406</id><published>2010-03-04T22:38:00.001Z</published><updated>2010-03-05T21:18:06.609Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-05T21:18:06.609Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="&quot;SQL Server&quot;" /><title>SQL Server Dynamic SQL</title><content type="html">The use of dynamic SQL is unfortunately one of those necessary evils that plagues developers and DBAs alike.&lt;br /&gt;
&lt;br /&gt;
Now I know that the use of the word "necessary" will irk some people but after developing BI systems for about 9 years I can assure you that it is. Sure, there are alternatives in a lot of cases, which I have learnt over time, but even so there are occasions where even those don't help. Things like synonyms can help as can linked views but there are still times when dynamic SQL is required. &lt;br /&gt;
&lt;br /&gt;
Either way, I'm not aiming this post to discuss the merits or demerits of dynamic SQL but rather at giving some airtime to a friendly yet oft unused SQL Server function. First off, hands up me 'cos I very rarely use this function too though I do have a mitigating factor.    &lt;br /&gt;
&lt;br /&gt;
Essentially we all know (or at least we should) that it is good practice to use qualified object names and that one should delimit object names to prevent runtime errors with bad practice object names. Some column and table names I've seen in my time include names with spaces, dollar signs, quotation marks etc. all of which I regard as evil. Let's not also forget the use of reserved words as object names which cannot always be easily avoided.&lt;br /&gt;
&lt;br /&gt;
So here's my mitigating factor. I have been lucky enough to be the technical lead on most projects where I am a bit of a hardcase on naming conventions so I have control over what objects are called and created. For those that aren't so lucky...&lt;br /&gt;
&lt;br /&gt;
Enter from stage left: The QUOTENAME function. &lt;br /&gt;
&lt;br /&gt;
Look it up in BOL, it's great. That little function will place the correct delimiters around a given string to present a well formed object name. This means you don't have to specify square brackets, or whatever delimiter you are using in your dynamic SQL. Obviously though, you will have that function scattered throughout your code unless you declare object names up front using the function, placing the results into parameters and then using those parameters in the string concatenation.&lt;br /&gt;
&lt;br /&gt;
Whether or not you use the function is by the by I guess, the main thing is to always delimit your object names. Still, it's good to know that the functionality exists if you ever need it. &lt;br /&gt;
&lt;br /&gt;
- Posted using BlogPress from my iPhone&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-8354085012938259406?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/NnebXrnWsNc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/8354085012938259406/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2010/03/sql-server-dynamic-sql.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/8354085012938259406?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/8354085012938259406?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/NnebXrnWsNc/sql-server-dynamic-sql.html" title="SQL Server Dynamic SQL" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>1</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2010/03/sql-server-dynamic-sql.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIFQ3g6cSp7ImA9WxBVE0Q.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-275256436227431109</id><published>2010-02-11T19:38:00.000Z</published><updated>2010-02-17T08:15:12.619Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-17T08:15:12.619Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SSIS" /><title>SSIS Script Task Custom Events</title><content type="html">So, an interesting observation regarding SSIS 2008, or should I say anoyance?&lt;br /&gt;&lt;br /&gt;At the moment I am part of a team building a data warehouse for an investment bank. Part of this system uses SSIS 2008 (or DTS100 in object model speak) in order to load batches at regular intervals into the warehouse. To ease the monitoring and issue resolution aspects of systems of this nature, we are aiming to use NetAgent to poll the database for new events of interest. Events such as load starts, failures, completion and dimension and partition processing activities all need to trigger an email or something to notify support of the system state.&lt;br /&gt;&lt;br /&gt;Well, now you might think, like me, that rather than just polling for "PackageStart" events or any of the other "standard" events we could create our own events that could be used to trigger alerts. Yup, now normally I'd say good idea, but alas this time I can't, I don't think... &lt;br /&gt;&lt;br /&gt;See, now in SSIS you could add a script task and using either C# or, shudder, VB .net, use Dts.Events.FireCustomEvent, or a derivation thereof, depending on the language chosen, to fire an event. Using this approach you could quite nicely craft your own custom events, giving you the ability to uniqely name this event. (I would presume that doing this would provide a unique name in the [source] column in the [sysssislog] table such that the event would now be uniquely identifiable, though documentation around all of this appears sparse, at best). One snag though...&lt;br /&gt;&lt;br /&gt;Now before I get to the proposed gotcha I guess I should 'fess up... I've only been using SSIS in any guise for about 9 months, so by no means am I a seasoned veteran of the product. Thus quite possibly there is a solution to this gotcha. Just maybe not an intuative one? (Hmmmm speaking of intuative, just don't get me started on case sensitive lookups. I know that they may well be quicker but really? WTF?)&lt;br /&gt;&lt;br /&gt;Anyhoo, so now that you have your über cool custom event, here's the issue. How do you get the SSIS package to log it? If you edit the logging properties of the package, even specifically selecting the script task, you are only presented with the predefined events for logging. You may be able to "load" the custom events or perhaps edit the package XML but really?&lt;br /&gt;&lt;br /&gt;So long story short, if someone knows of a way to get an SSIS package to log script task defined custom events, please don't be shy and let me know...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- Posted using BlogPress from my iPhone&lt;br /&gt;&lt;p class='blogpress_location'&gt;Location:&lt;a href='http://maps.google.com/maps?q=Somewhere%20on%20South%20West%20Trains&amp;z=10'&gt;Somewhere on South West Trains&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-275256436227431109?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/gT5Hfz4ZVuM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/275256436227431109/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2010/02/ssis-script-task-custom-events.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/275256436227431109?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/275256436227431109?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/gT5Hfz4ZVuM/ssis-script-task-custom-events.html" title="SSIS Script Task Custom Events" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>2</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2010/02/ssis-script-task-custom-events.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4CQnk4cSp7ImA9WxBUGE8.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-6270679243314729345</id><published>2009-12-17T06:49:00.002Z</published><updated>2010-03-05T21:19:23.739Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-05T21:19:23.739Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="&quot;SQL Server&quot;" /><title>SQL Server 2008 SP1 - Cannot drop database because it is currently in use.</title><content type="html">&lt;div&gt;Recently I came across an issue in SQL Server 2008 SP1 where I was trying to rebuild our DEV databases from script (we have Nant scripts that perform a continuous build process so we know that they work) but during the rebuild the process failed because one of the databases could not be dropped. At first I thought that there must be existing connections to the database but a quick review of the output of "sp_who2" showed no such thing.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Anyway, to shortcut the whole build process I figured I would just use SQL Server Management Studio to manually drop the database and enable the "force close existing connections" option. However, this too failed saying that the database was currently in use, even with the "force close" option set and even more bizarrely once again when I checked the output of "sp_who2", I could not see any connections to the particular database in question. Restarting the SQL Server service didn't help either.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;A quick Google search on this error message produced quite a few hits (as you probably know if you found this page that way), a lot of which seemed to indicate that the way to resolve this is to alter the database into single user mode with the immediately rollback option set. Using this produced no joy for me either, which wasn't really surprising considering that there appeared to be no connections in the first place.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;In the end, this is how I solved it… You need to get SQL Server to tell you who is blocking the drop command. Not rocket science is it, once you know the answer. ;-) So…&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;First of all, using SQL Server Management Studio, open a query window on to the server and ensure that it is connected to the [master] database.&lt;/li&gt;
&lt;li&gt;Next, also using SQL Server Management Studio, right click on the database in question and select the option to drop the database and enable the "close existing connections" option. Click OK.&lt;/li&gt;
&lt;li&gt;While this is trying to drop the database, quickly switch to the open query window and run "sp_who2". Look through the result set for the  row with a status of "SUSPENDED" and note the value in the "BlkBy" column.&lt;/li&gt;
&lt;li&gt;Also in the query window, execute the kill command to kill the spid with the value noted in the point above.&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;And there you go, the database will have been dropped as soon as you killed the SPID.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Wierd eh?&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-6270679243314729345?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/u1aG2yc5XU4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/6270679243314729345/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2009/12/sql-server-2008-sp1-cannot-drop.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/6270679243314729345?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/6270679243314729345?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/u1aG2yc5XU4/sql-server-2008-sp1-cannot-drop.html" title="SQL Server 2008 SP1 - Cannot drop database because it is currently in use." /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>0</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2009/12/sql-server-2008-sp1-cannot-drop.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8CRXc4fip7ImA9WxJWFko.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-4105281511848861930</id><published>2009-06-22T12:05:00.003+01:00</published><updated>2009-06-22T13:47:44.936+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-22T13:47:44.936+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Analysis Services" /><category scheme="http://www.blogger.com/atom/ns#" term="Default Member" /><title>Analysis Services 2005 - Dynamic Default Member</title><content type="html">Whilst migrating a database from AS2000 to AS2005 I came across in interesting issue when trying to replicate the same behaviour as the "legacy" version. Firstly, a little background...&lt;br /&gt;&lt;br /&gt;For the sake of expediency I used the migration wizard to convert most of the AS2000 database over to AS2005. I say most because although the validation checker stated that everything was a-okay, when it came to actually do the migration the wizard whinged about a dimension that was joined to different cubes at different levels within the dimension. In order to progress this, I deleted the dimension and migrated the rest.&lt;br /&gt;&lt;br /&gt;So, what I was left with was a pretty complete system that, although not overly complex, it wasn't trivial either. The database contained a number of cubes and virtual cubes etc. and they contained a financial line dimension making use of unary operators and custom MDX for specific members. When designing the AS2000 database originally, I specifically avoided calculated cells so there were none of those but it did contain quite a number of calculated members. I must say that I was actually quite impressed with the conversion process once it worked. Certainly the dimensions were migrated quite well, though it made a bit of a mess of migrating the "alternate hierarchy" dimensions. I'm also not a big fan of using linked measure groups etc. so I'll probably back those out into a series of cubes using multiple measure groups etc. but I digress.&lt;br /&gt;&lt;br /&gt;Whilst going through all the dimensions, to compare the migrated version to the original version, I noticed that the [Currency] dimension had not been migrated to be the same as the original. The dynamic default member definition was missing and needed to be added back. Now, based on AS2000 functionality, the [Currency] dimension had the default member defined using the "Filter" function to filter the members of the dimension based on a "Default Flag" member property such that when the member property was "1" it identified the default member.&lt;br /&gt;&lt;br /&gt;In AS2005 the preferred method is to use the "Exists" function and it performs a lot better than filtering. Indeed, there is also a known issue in AS2005/8 where use of the "Properties" function when specifying a default member causes heap corruption during processing so it should be avoided. Now the interesting bit, The currency dimension does not have an "all" level so I set the "IsAggregatable" property to false, changed the "Default Flag" attribute's "AttributeHierarchyEnabled" property to true, to change it from a member property to a true attribute and set about deploying and processing the revised dimension. All of that resulted in the following error:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Errors in the metadata manager. The 'Currency' attribute with IsAggregatable=false must not have any relationship to 'Default Flag' attribute that has AttributeHierarchyEnabled=true&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So, rather interestingly, you cannot have attribute 'x' related to attribute 'y' if attribute 'y' has its "IsAggregatable" property set to false. Converting attribute 'x' to a member property serves to allow the dimension to deploy but prevents the use of the attribute in the "Exists" function. One would have to revert back to the use of the "Filter" function which we really need to avoid. Now I'm not sure why this limitation exists, it just does. So how to work around it?&lt;br /&gt;&lt;br /&gt;Well what I did, was to create a copy of the key attribute and have it related to the key. I changed the attribute relationship to "Rigid", as this should never change, and the cardinality to "one to one" even though this latter property isn't used in AS2005. Then, on the key attribute, I set the "IsAggregatable" property to true, the "AttributeHierarchyVisible" property to false and left the "Default Flag" attribute relationship on the key. The key also had to be renamed so I added an underscore to the end of it.&lt;br /&gt;&lt;br /&gt;On the copied attribute (i.e. the copy of the key) I renamed it to the name of the key attribute but without the underscore, set the "IsAggregatable" property to false and defined the default member with MDX using the "Exists" function and the "Default Flag" attribute as follows:&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Exists&lt;/span&gt;([Currency].[Currency].[Currency].&lt;span style="color: rgb(51, 51, 255);"&gt;Members&lt;/span&gt;, [Currency].[Default Flag].&amp;amp;[1]).&lt;span style="color: rgb(51, 51, 255);"&gt;Item&lt;/span&gt;(0)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This appears to do the trick at the expense of duplicating the attribute, providing a dynamically set default member on an attribute that is not aggregatable.&lt;br /&gt;&lt;br /&gt;I hope this helps others out there who may face the same issue and hey, if you know why you can't do this straight on the key, please enlighten me!&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-4105281511848861930?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/Aa0akRtTJqg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/4105281511848861930/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2009/06/analysis-services-2005-dynamic-default.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/4105281511848861930?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/4105281511848861930?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/Aa0akRtTJqg/analysis-services-2005-dynamic-default.html" title="Analysis Services 2005 - Dynamic Default Member" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>1</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2009/06/analysis-services-2005-dynamic-default.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0QFQHc5eCp7ImA9WxJREEg.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-6308576283147853036</id><published>2009-05-11T14:36:00.006+01:00</published><updated>2009-05-11T15:15:11.920+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-11T15:15:11.920+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="CentOS" /><category scheme="http://www.blogger.com/atom/ns#" term="Subversion" /><category scheme="http://www.blogger.com/atom/ns#" term="Linux" /><title>Installing Subversion from source on CentOS 5.2</title><content type="html">Okay so this not strictly BI related but hey, most of us BI types have a slight geek inclination don't we, or is that just me?&lt;br /&gt;&lt;br /&gt;I guess the main reason for blogging about this is that I really didn't expect this to be that hard. I mean, I've been installing Subversion from source since about Fedora Core 3 without issues (other than when the Subversion/Berkley DB integration underwent some changes that shafted access to my repositories) so I kinda expected the same here. Um, wrong! At least this time the issue related to a fresh install rather than suddenly finding that I can no longer access my repositories. Needless to say I now use FSFS rather than Berkley DB as the back-end but still. A friend of mine also works on FSFS (see: &lt;a href="http://www.farside.org.uk/200704/tree_structured_fsfs"&gt;http://www.farside.org.uk/200704/tree_structured_fsfs&lt;/a&gt;) so he'd been going on at me for a while to switch. Still took that heartache to make me use FSFS though, groan...&lt;br /&gt;&lt;br /&gt;Anyway, so a while back (meant to blog about this a long time ago but based on how long it has been since my last blog, I can see that it really was a loooong time ago) I set about compiling Subversion from source code. I guess there are many reasons for installing Subversion from source code but that's immaterial here. Needless to say that I started and soon came to realise after running &lt;span style="font-family:courier new;"&gt;./configure&lt;/span&gt; that there were some missing dependencies when trying to enable SSL. After a little bit of searching and running &lt;span style="font-family:courier new;"&gt;rpm -qa&lt;/span&gt; etc. to find if certain libraries were installed I found that my install of CentOS was missing the &lt;span style="font-family:courier new;"&gt;openssl-devel&lt;/span&gt; library. So, a quick install using &lt;span style="font-family:courier new;"&gt;yum&lt;/span&gt; and I was away, or was I?&lt;br /&gt;&lt;br /&gt;Okay, so maybe not. After installing the missing library another error occurred during the &lt;span style="font-family:courier new;"&gt;./configure&lt;/span&gt; script run. This particular issue, however, is documented in the Subversion documentation and requires you to amend the parameters passed to the &lt;span style="font-family:courier new;"&gt;configure&lt;/span&gt; command in order to have the information passed through to the "&lt;span style="font-family:courier new;"&gt;sub-configure&lt;/span&gt;" scripts. Rather bizarrely you need to specify the &lt;span style="font-family:courier new;"&gt;--with-libs&lt;/span&gt; parameter, specifying "&lt;span style="font-family:courier new;"&gt;/usr/kerberos&lt;/span&gt;" as the value. (i.e. &lt;span style="font-family:courier new;"&gt;--with-libs=/usr/kerberos&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;I guess the part that really got me for a while was the fact that when you run the &lt;span style="font-family:courier new;"&gt;configure&lt;/span&gt; script, passing in the above mentioned switch, a message is generated on the first line stating: "&lt;span style="font-family:courier new;"&gt;configure: WARNING: unrecognized options: --with-libs&lt;/span&gt;" however this message can be safely ignored. That little tidbit of information is not specified in the documentaion. So, if you leave the script to run it should actually run to completion, barring any other issues naturally.&lt;br /&gt;&lt;br /&gt;Long and short of it is that in order to compile Subversion with SSL enabled on CentOS 5.2 (well with the my install base anyway) I had to do the following:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;# Unpack the source&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;tar -zxvf subversion-&lt;version&gt;&lt;version&gt;&amp;lt;version&amp;gt;.tar.gz&lt;/version&gt;&lt;/version&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;cd subversion-&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;version&gt;&lt;/version&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;# Check that openssl-devel has been installed.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;yum list openssl-devel&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;# If not, install using the following:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;yum install openssl-devel&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;# Configure and install subversion with FSFS,&lt;br /&gt;# ignoring message "configure: WARNING:&lt;br /&gt;# unrecognized options: --with-libs".&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;./configure --without-berkeley-db --with-ssl --with-libs=/usr/kerberos&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And that's all there is to it!&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-6308576283147853036?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/y6422soihjo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/6308576283147853036/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2009/05/installing-subversion-from-source-on.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/6308576283147853036?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/6308576283147853036?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/y6422soihjo/installing-subversion-from-source-on.html" title="Installing Subversion from source on CentOS 5.2" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>0</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2009/05/installing-subversion-from-source-on.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkYERn07cSp7ImA9WxVVF08.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-1478719410570678767</id><published>2009-03-10T22:38:00.003Z</published><updated>2009-03-10T23:35:07.309Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-10T23:35:07.309Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Plugin" /><category scheme="http://www.blogger.com/atom/ns#" term="Analytic Workspace Manager" /><category scheme="http://www.blogger.com/atom/ns#" term="AWM" /><title>Analytic Workspace Manager Locking</title><content type="html">So, following on from my previous blog about plugins for the AWM, I thought I would provide a little information about something I learned whilst writing my own plugin.&lt;br /&gt;&lt;br /&gt;Writing a plugin for the AWM and testing it can be cumbersome if you have to constantly start the AWM, login and then navigate to a node in the tree that allows you to activate your plugin. No, arguably a better way is to create your own testbed to simulate the AWM environment. That way you can run your code with less effort and interaction and are also afforded the ability to step through and debug your code if, like me, you need to.&lt;br /&gt;&lt;br /&gt;In my case I merely created a Java class that effectively created an Oracle database connection and then called my plugin code, passing in the connection and anything else that it required. This was all fine and dandy whilst developing the code and afforded me the luxury of being able to test my code with the minimum of effort. However, when I eventually placed my code into the plugin framework (which to be fair I was doing simultaneously anyway) my code, well, didn't really stop working but rather, well... just seemed to stall.&lt;br /&gt;&lt;br /&gt;This was masked by the fact that I was using multiple threads and thus parts of the plugin, though still functioning, arguably produced incorrect results. After a little investigation (okay, okay, so more than a little and certainly more than I would have liked) I discovered the reason...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic;"&gt;There appears to be no fine-grained locking in Oracle OLAP, certainly as far as the AWM is concerned.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So what do I mean by that? Well, just that it is geared towards a single developer updating a given analytic workspace. Multiple updates to different parts of the workspace simultaneously are not supported nor, as far as I can tell, even possible.&lt;br /&gt;&lt;br /&gt;So what does that mean to us? Well, when the AWM connects to the analytic workspace it attaches it in "read/write" mode. This means that any plugin code can only affect the contents of that analytic workspace by using the connection provided to it when the plugin is invoked. Retrieving/creating a new connection using the data source made available in the Map object presented to the plugin means that any code executed over that connection is in fact in a different session. As such, any code intended to affect the same analytic workspace that was attached by the AWM session created when the analytic workspace was attached will be blocked and will not be able to make changes or even process any objects in that analytic workspace.&lt;br /&gt;&lt;br /&gt;At first I thought that that was it, game over but there is a "trick". This "trick", albeit a bit of hack and one not to be taken lightly, involves the use of the &lt;span style="font-family: courier new;"&gt;DBMS_AW&lt;/span&gt; package . More specifically, the use of the &lt;span style="font-family: courier new;"&gt;DETACH&lt;/span&gt;, &lt;span style="font-family: courier new;"&gt;UPDATE&lt;/span&gt; and &lt;span style="font-family: courier new;"&gt;ATTACH&lt;/span&gt; sub-programs allowing us to detach the analytic workspace over the main connection provided by the AWM to the plugin code. We can then "re-attach" it on the new connection in read-only mode (or read/write if you want) and perform whatever actions you would like on the given analytic workspace. The &lt;span style="font-family: courier new;"&gt;UPDATE&lt;/span&gt; sub-program is required in order to commit any changes that have already been made to the analytic workspace whilst it was in read/write mode prior to detaching it.&lt;br /&gt;&lt;br /&gt;Note that there is a potential issue here. Detaching the analytic workspace and re-attaching it introduces the risk that in the meantime another session locks the workspace before the plugin secures it for its own use. Also, failure to ensure that the analytic workspace is attached in read/write mode before the plugin exits breaks the environment in which the AWM expects to function. (i.e. The AWM still "thinks" that the workspace is attached in read/write mode and will allow a user to try to make changes even though this may not be the case.)&lt;br /&gt;&lt;br /&gt;Clearly the functionality that this provides needs to be weighed in conjunction with the expected working environment and the associated risks. If the environment is inherently single-user then no harm is done. However, if there is a multi-user environment where multiple people are likely to request read/write locks on the same analytic workspace, well, then your mileage may vary. Clearly you may be able to use transactions to mitigate some, if not all, of these risks but that remains to be seen.&lt;br /&gt;&lt;br /&gt;As mentioned previously, oh how nice it would have been to be able to lock a specific dimension or cube etc. which, based on the metadata stored in the database, appears quite possible but just not implemented. This could have opened up opportunities for multi-user development environments to allow teamed development, maintenance and testing etc. What a novel concept, though sorely lacking here...&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-1478719410570678767?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/hHdrFiEfM5A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/1478719410570678767/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2009/03/analytic-workspace-manager-locking.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/1478719410570678767?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/1478719410570678767?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/hHdrFiEfM5A/analytic-workspace-manager-locking.html" title="Analytic Workspace Manager Locking" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>2</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2009/03/analytic-workspace-manager-locking.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkYESXs5eSp7ImA9WxVXGEs.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-9131886026869939742</id><published>2009-02-16T08:23:00.006Z</published><updated>2009-02-17T08:41:48.521Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-17T08:41:48.521Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Plugin" /><category scheme="http://www.blogger.com/atom/ns#" term="Analytic Workspace Manager" /><category scheme="http://www.blogger.com/atom/ns#" term="AWM" /><title>Analytic Workspace Manager Plugin Best Practices</title><content type="html">The Analytic Workspace Manager (or AWM for short) is the tool to use when wanting to quickly create OLAP structures in the Oracle OLAP engine embedded within the Oracle relational database. Clearly you can use OWB etc. but AWM provides a lightweight easy to use interface for creating quick demos, restructuring content or processing etc. However, what the AWM provides may well not be everything to everyone and thus it is possible to create your own plugins, using Java, to get it to do what &lt;span style="font-style: italic;"&gt;you&lt;/span&gt; want.&lt;br /&gt;&lt;br /&gt;The documentation around doing this, I found, is a little light on the ground so to speak. So I have tried to document my findings here to help those that may wish to follow suit. However, before I start I should probably point out that in no way is the following post endorsed by Oracle. These are merely my observations after coding my own plugin for the Analytic Workspace Manager.&lt;br /&gt;&lt;br /&gt;So here goes...&lt;br /&gt;Step one is to find the &lt;a href="http://www.oracle.com/technology/products/bi/olap/11g/awm_plugin/developing_awm_plugins_11g.pdf"&gt;Developing_AWM_Plugins_11g.pdf&lt;/a&gt; document. When I started coding  my plugin for the 11g version of AWM, I could only find the 10g document which is not quite accurate for 11g. The OLAP API has changed somewhat in 11g and this is reflected in the OLAP API interface between the AWM and user plugin code. Looking at the document, I guess the pertinent points are that the 11g version of AWM requires the plugin to be compiled with Java 5 SE. (Or version 1.5 in "old school", just why did Sun confuse matters?) We'll come back to this but suffice to say that you'll need to remember that Java 5 brings with it support for generics.&lt;br /&gt;&lt;br /&gt;Also in the document, if you have coded for 10g plugins, you may notice that the interface method signatures have changed a little. The &lt;span style="font-style: italic;"&gt;AW&lt;/span&gt; object passed into the &lt;span style="font-style: italic;"&gt;handle&lt;/span&gt; method is now an &lt;span style="font-style: italic;"&gt;oracle.AWXML.AW &lt;/span&gt;object. The &lt;span style="font-style: italic;"&gt;params&lt;/span&gt; parameter to the &lt;span style="font-style: italic;"&gt;handle&lt;/span&gt; method provides a map, where the DATAPROVIDER key provides the ability to get a connection to the underlying Oracle database without requiring username/password information.&lt;br /&gt;&lt;br /&gt;Step two, and arguably the most important step, is the understanding that on startup the Analytic Workspace Manager loads all Java code in the plugin directory and looks for any class files that implement the &lt;span style="font-style: italic;"&gt;AWMPlugin&lt;/span&gt; interface. This is also documented in the above mentioned document, however, what is not made clear is that there will naturally be a performance impact on the startup time of AWM, the more classes and JAR files that you add to the plugin directory. Also, if you use 3rd-party JAR files you are at the mercy of those maintainers.&lt;br /&gt;&lt;br /&gt;For example, placing the "jfreechart" JAR files in the plugin directory causes exceptions to be thrown in the AWM command window regarding missing Eclipse files. (I'm guessing that "jfreechart" is coded using Eclipse and some code dependencies are left behind.) Allowing this to happen with a user-defined plugin is pretty inelegant at best but most likely just down-right rude. We should avoid that, and we can.&lt;br /&gt;&lt;br /&gt;The best practice I have come up with is as follows:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The interface between the AWM and your plugin should reside in its own JAR file and only contain the minimum number of class files etc. in order to start the actual plugin. This keeps the startup time for the AWM to the minimum.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;The actual plugin code should be packaged into its own JAR file and placed elsewhere in the file system. (I use a subdirectory of the plugin directory so that it can be found using relative paths from the plugin interface.)&lt;/li&gt;&lt;li&gt;Associated plugin dependencies should also be placed into a subdirectory (I use the same one as my own code as mentioned above) of the plugin directory.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Now, Oracle kindly provide a directory from which plugins can be found and executed but this clearly isn't scalable from a startup point of view if you require the use of large dependencies or lots of plugins. Oracle unfortunately &lt;span style="font-style: italic;"&gt;don't&lt;/span&gt; provide the equivalent of an "&lt;span style="font-style: italic;"&gt;Ext&lt;/span&gt;" directory into which dependencies could be placed. So here's the dilemma... Do we customise the Windows batch file (or *nix shell script) to include our dependencies in the classpath, or do we place our dependencies in one of the directories that is already referenced by the Oracle prescribed classpath?&lt;br /&gt;&lt;br /&gt;My answer... neither! Customising the startup script is prone to failure if Oracle ever decide to update it. It also means deploying the plugin is a pain, in that everyone's installation may be different so deploying the script needs to take that into consideration. Hijacking the Oracle directories is also pretty "rude" and prone to cause issues down the line, not to mention taking into consideration once again the uniqueness of each installation. No, best practice would be to customise a URLClassLoader in order to dynamically load the dependencies at runtime and start the plugin. This unfortunately requires the use of reflection and is a bit more long winded but it will be far more robust and stand you in good stead during further developments.&lt;br /&gt;&lt;br /&gt;My plugin used both "log4j" and "jfreechart", both of which had to be loaded onto the classpath with "log4j" needing to be instantiated in order to log progress. &lt;span style="font-style: italic;"&gt;I may blog more on this in detail in the future, as doing this can be tricky and I couldn't find a definitive guide on this on the web.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Finally, coming back to generics, note that the &lt;span style="font-style: italic;"&gt;AWMPlugin&lt;/span&gt; interface needs to be backwards compatible and as such does not make use of generics. This tends to generates compiler warnings. The way I would recommend handling this is to annotate the interface methods with "&lt;span style="font-style: italic;"&gt;@SuppressWarnings("unchecked")&lt;/span&gt;" to suppress those warnings but only on the methods provided by Oracle. If you need to assign one of the variables found in the interface parameter list to to your own variable, you can use the generic wildcard, such as declaring "Map&amp;lt;?&amp;gt;", indicating the supertype.&lt;br /&gt;&lt;br /&gt;And that's all there is to it.&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-9131886026869939742?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/DQ0JWAnOqtU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/9131886026869939742/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2009/02/analytic-workspace-manager-plugin-best.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/9131886026869939742?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/9131886026869939742?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/DQ0JWAnOqtU/analytic-workspace-manager-plugin-best.html" title="Analytic Workspace Manager Plugin Best Practices" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>0</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2009/02/analytic-workspace-manager-plugin-best.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEICQn8zeip7ImA9WxVXF0o.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-5127301204142010251</id><published>2009-02-02T11:55:00.005Z</published><updated>2009-02-16T08:22:43.182Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-02-16T08:22:43.182Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Analysis Services" /><title>Analysis Services 2005/2008 Heap Corruption</title><content type="html">Recently I have been working for a financial institution who are using Analysis Service 2005 for their ad-hoc analysis. This particular client was experiencing issues with one of the Analysis Services servers producing memory mini-dump files during processing and causing service crashes and stalls whilst other servers were performing acceptably well.&lt;br /&gt;&lt;br /&gt;The analysis of this issue started towards the end of 2007 and the reason for this has only now been diagnosed with the able help of Microsoft support. The particular system setup for this client is quite complex, using Oracle 10gR2 as the back-end relational database using flashback for referential integrity and consistency, the 11g (11.1.0.6.0) 64 bit OLE DB driver for connectivity from AS to Oracle and SSIS for scheduled processing. The AS database also makes extensive use of linked measure groups in order to provide a single cube of data with mixed granularity.&lt;br /&gt;&lt;br /&gt;In order to diagnose the cause of the heap corruption we had to jump through quite a series of hoops. We initially went down the route of sending the mini-dump files to Microsoft for analysis but these naturally only provided limited and static information. Sending full dump files proved very tricky in the short term as the information that the cubes contain is confidential and cannot be sent off-site. In the end, restarting AS and only processing the dimensions and cubes (i.e. no queries being sent to AS) proved adequate to be able to send the full memory dump files off-site, as it would be extremely hard to put this in-memory information together in any meaningful way.&lt;br /&gt;&lt;br /&gt;Still, the full dump files are also static and thus proved inconclusive. It could be seen from the dump files that heap corruption was indeed occuring during processing and there always appeared to be an Oracle error in the dump file as well. It seemed logical that the Oracle 11g driver could be the cause, as most clients tend to use the 10.2.0.3.0 Oracle OLE DB driver when connecting to Oracle 10.2.0.3.0 or later. In order to try and eliminate the 11g driver as the cause, we backed out the 11g driver and installed the 10.2.0.3.0 driver. (&lt;span style="font-style: italic;"&gt;Note that in true Oracle fashion, this proved to be an exercise in and of itself. There is no Oracle 10.2.0.3.0 64 bit client installation. Noooooooo, that's waaaaay too easy! You have to install 10.2.0.1.0 and then patch it to 10.2.0.3.0. Oh, but wait, there is a patch before you apply the patch in order to get the patch to work etc. yadayadayada.&lt;/span&gt;) Anyhoo, I digress...&lt;br /&gt;&lt;br /&gt;In the end, we found that using the Oracle 10.2.0.3.0 driver did not fix the problem. The next step then, was to divide and conquer so to speak...&lt;br /&gt;&lt;br /&gt;Part one was to try and create a reduced test case by systematically removing complexity from the AS database. This was achieved by first removing the linked measure groups (I'm not aware of many people using this feature) and then to remove cubes and dimensions until a simple AS database could be created in which the issue could still be reproduced. The idea of this approach was to be able to get a small AS database with a tiny amount of non-confidential data so that Microsoft could perform in-house testing.&lt;br /&gt;&lt;br /&gt;Part two was to use Time Travel Trace testing (TTT) which effectively allows one to debug the issue by being able to play forward and rewind the process over a given time span. This would allow one to see the changes made to the heap and replay them to identify the point at which the heap was corrupted. Rather amusingly though, there is a slight catch. This system was using AS2005 on Windows Server 2003 as are most installations I would suspect. However, TTT only works on Windows Server 2003 on a 32 bit architecture or Windows Server 2008 on a 64 bit architecture or if virtualised, only on Hyper-V.&lt;br /&gt;Right, so a few changes to the test case then. As it happened we used a 32 bit environment and as luck would have it we were actually able to reproduce the issue, though TTT failed to work. Initially it exhibited the same symptoms as seen when used on Vista, where it "watched" the incorrect "thread" for activity. This should have been fixed be setting the processor affinity for AS. It wasn't...&lt;br /&gt;&lt;br /&gt;As it happens, the TTT testing wasn't required. The reduced test case was effective and we were able to remove all confidential data. Microsoft took this in-house and managed to find the answer. So, are you ready for this? Do you want to know why memory heap corruption was occurring during processing? Well, do you?&lt;br /&gt;&lt;br /&gt;Rather bizarrely, the reason for the heap corruption was the use of the "&lt;span style="font-family:courier new;"&gt;.Properties&lt;/span&gt;" function when specifying the default member in a dimension. Yup, the use of a specific function when specifying the default dimension member caused heap corruption during processing, not querying but &lt;span style="font-style: italic;"&gt;processing&lt;/span&gt;. So how lucky am I that the reduced test case that I created used one of the only two dimensions out of 30 odd using that function when specifying the default member? Now I'm not sure why that function causes the issue and nor are the AS development team. They are still looking into it and  from what I understand, were equally surprised. As it happens, the MDX that was being used to specify the default member wasn't particularly efficient in the first place (I must point out that it wasn't my code) and that once the code was changed to use the "&lt;span style="font-family:courier new;"&gt;Exists&lt;/span&gt;" function, it solved the problem.&lt;br /&gt;&lt;br /&gt;Clearly your mileage may vary but nonetheless please be aware that the use of the "&lt;span style="font-family:courier new;"&gt;.Properties&lt;/span&gt;" function when specifying the default dimension member can cause heap corruption during processing. This is true for both AS2005 CU11 (or SP3 CU1) and AS2008 CU2. I'm still not sure why this only occurred on one of the servers when the other servers have the exact same database build but hey, removing the "&lt;span style="font-family:courier new;"&gt;.Properties&lt;/span&gt;" function solved the issue so clearly that was the problem.&lt;br /&gt;&lt;br /&gt;You have been warned...&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-5127301204142010251?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/VuQPMB7X6Wc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/5127301204142010251/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2009/02/analysis-services-20052008-heap.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/5127301204142010251?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/5127301204142010251?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/VuQPMB7X6Wc/analysis-services-20052008-heap.html" title="Analysis Services 2005/2008 Heap Corruption" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>4</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2009/02/analysis-services-20052008-heap.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4CR305eip7ImA9WxRXFkw.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-1865349889652433936</id><published>2008-10-21T18:55:00.004+01:00</published><updated>2008-10-21T19:49:26.322+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-21T19:49:26.322+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Oracle 11g" /><category scheme="http://www.blogger.com/atom/ns#" term="Analytic Workspace Manager" /><category scheme="http://www.blogger.com/atom/ns#" term="AWM" /><category scheme="http://www.blogger.com/atom/ns#" term="Oracle OLAP" /><title>Is Oracle AWM 11.1.0.7.0A Better?</title><content type="html">So, I'm about to present at a workshop tomorrow on Oracle 11g's Interval Partitioning and on the OLAP option and in preparation for the event I have had to create a demo. A while back I patched our 11.1.0.6.0 relational database to patch 8 but although both patch 10 and 11.1.0.7.0 have since been released, I decided not to risk upsetting things too much by installing those and have thus gone with the status quo. (Note that we have &lt;span style="font-style: italic;"&gt;lots&lt;/span&gt; of Oracle software on that machine for demos and breaking things at any time is just not on!)&lt;br /&gt;&lt;br /&gt;Incidentally, I just &lt;span style="font-weight: bold;"&gt;have&lt;/span&gt; to ask, does anyone actually &lt;span style="font-style: italic;"&gt;know&lt;/span&gt; what each number in Oracle's version numbers stand for? I searched a while back but to no avail. But I digress...&lt;br /&gt;&lt;br /&gt;Searching around on 11g versions and patches I came across an article that said that in order to patch the OLAP option you need to install either Patch 'A' or Patch 'B' but in order to patch the relational side of the engine you use the Patches 6, 8, 10 etc. Huh? When I installed patch 8 it had to back out patch 'A' (which is what the person who posted on the forum also found) so does that mean that the OLAP patches are mutually exclusive from the relational patches? That's a question I have yet to answer 'cos maybe you are meant to re-apply Patch 'A' after patch 8 etc. but that's a subject for a later post. (Especially since 11.1.0.7.0 has been released which appears to be for both relational and OLAP with patch #6890831. See the &lt;a href="http://www.oracle.com/technology/products/bi/olap/collateral/olap_certification.html"&gt;OLAP Certification&lt;/a&gt; page.)&lt;br /&gt;&lt;br /&gt;Anyhoo, my big grumble with the Oracle Analytic Workspace Manager is that it seems to contain more bugs than an anthill. Seriously, does anyone actually &lt;span style="font-style: italic;"&gt;test&lt;/span&gt; this thing? Within 2 minutes of using it I can get it to break. Lol, now I appreciate that my ineptitude is clearly a culprit in this issue in that if I did everything correctly it wouldn't break. However, exceptions are just that, exceptions and they need to be catered for.&lt;br /&gt;&lt;br /&gt;Documentation seems to indicate that the preferred method of creating analytic workspaces etc. is to use Oracle Warehouse Builder and that the Analytic Workspace Manager is for "end users" who don't have access to the ETL/ELT process. It can also be used where OWB is not the ETL/ELT tool being employed.&lt;br /&gt;&lt;br /&gt;Really? Whenever an exception is thrown I seem to get some Java exception ramblings about not being able to create a cursor or transaction or something equally inane. I'm sorry. It's coding like this that gives Java a bad name! Issues such as not being able to switch between a "star-schema" dimension and "snowflake" dimension after it has been built. Sure, you click on the drop down box and select it but sometimes the relevant member is selected but you don't get the correct representation in the mapping pane (i.e. visible/invisible "parent" member) or it just won't select.&lt;br /&gt;&lt;br /&gt;Other irritations include:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;After defining a cube you can click on the cube name in the schema tree and even though the dimensions are greyed out, you can double click an available dimension and it will appear to be added to the cube's dimension list. It hasn't really, click off the cube and come back and the model is back as expected.&lt;/li&gt;&lt;li&gt;Try creating a dimension over the "Sales Territory" dimension as available in the Microsoft AdventureWorks database and it will build. You can even browse it. However, join that dimension to a cube built off of the Internet Sales fact table and whoa... nasty exception.&lt;/li&gt;&lt;li&gt;Why does the above nasty exception terminate my connection and cause random stuff to happen?&lt;/li&gt;&lt;li&gt;How come building cubes off a database using the WE8MSWIN1252 characterset causes ORA-12704 characterset mismatch errors seemingly at random? Sometimes when I merely process something but always when trying to create cube organized materialized views. Sure I should be using UTF8 but the default for the "warehouse" database created by dbca is to use WE8MSWIN1252. What gives with that?&lt;br /&gt;&lt;/li&gt;&lt;li&gt;...&lt;/li&gt;&lt;/ul&gt;It is probably worth pointing out that the version of AWM that I was using was 11.1.0.7.0A and apparently that is expected to work against an 11.1.0.6.0 database. Maybe I should log these as bugs for Oracle to fix, I get that. My complaint though, is how did some of the issues I experience (maybe not listed here) even get through the door?&lt;br /&gt;&lt;br /&gt;Does anyone on the development team actually use the product in a way that is not based on contrived samples? We all know that clinical test cases will work but what about the real world?&lt;br /&gt;&lt;br /&gt;After all that, is the new version of AWM better? Yes. The fact that you can now create dimension levels at the time when you create a dimension (which I always thought was odd that you couldn't) is accepted with open arms. Despite all the ramblings above, it does seem a little more stable though that really isn't saying much. The default way of mapping columns to OLAP structures has changed from the graphical mapping view to the table mapping view which I think is for the better.&lt;br /&gt;&lt;br /&gt;Bottom line, if you haven't switched yet, switch now. It's better for sure but don't expect an "Analysis Services development environment (i.e. BIDS)" type experience or you'll be sorely disappointed!&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-1865349889652433936?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/o3y-89VdXGs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/1865349889652433936/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2008/10/is-oracle-awm-111070a-better.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/1865349889652433936?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/1865349889652433936?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/o3y-89VdXGs/is-oracle-awm-111070a-better.html" title="Is Oracle AWM 11.1.0.7.0A Better?" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>3</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2008/10/is-oracle-awm-111070a-better.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUUBQ3c9fCp7ImA9WxRQGU4.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-9149177002542770911</id><published>2008-10-13T22:25:00.004+01:00</published><updated>2008-10-13T23:34:12.964+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-13T23:34:12.964+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="EPM" /><category scheme="http://www.blogger.com/atom/ns#" term="Oracle" /><category scheme="http://www.blogger.com/atom/ns#" term="Enterprise Performance Management" /><category scheme="http://www.blogger.com/atom/ns#" term="Hyperion" /><title>Hyperion EPM on Windows Server 2008</title><content type="html">For an upcoming workshop we are running, covering the Oracle BI offering, I had to upgrade the relevant Oracle software to later versions. This included upgrading Oracle 11g to 11.1.0.6 patch 8 (11.1.0.7 not available for Windows at the time), upgrading Hyperion 9.3 to EPM Fusion edition and upgrading OBIEE plus. &lt;span style="font-style: italic;"&gt;As an aside, the upgrade to Oracle 11g wasn't exactly seamless due to some Hyperion 9.3 service mainting a reference to the Oracle client dlls despite the fact that I had "uninstalled" Hyperion prior to the 11g patching. However, the use of ProcessExplorer soon highlighted the offending process and I was able to complete the patching in due course.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Installing Oracle/Hyperion Enterprise Performance Management Fusion Edition on Windows Server 2008 however, seemed to pose some interesting challenges. I'm not sure if this is as a result of running the Windows Server 2008 as the OS, the fact that the OS is actually running in Hyper-V, the fact that I uninstalled Hyperion 9.3 first and then installed EPM or something else but the net result was that it took me almost 2 days to solve an issue with OpenLDAP.&lt;br /&gt;&lt;br /&gt;Attempts to start the Hyperion OpenLDAP service were unsuccessful and thus none of the other services were able to register with Shared Services. (i.e. The Shared Services service requires the OpenLDAP service to be up and running before it can start.) The failure to start the service provided little in the way of messages that would help debug the issue but consulting the EPM installation documentation (and Google) showed that you can start the OpenLDAP service from the command line using the "-d" switch in order to get some logging to sdtout. A switch of "-d 1" provides copious volumes of logging information and "-d -1" even more so. ;-)&lt;br /&gt;&lt;br /&gt;Although this did produce some logging, in the end it was of little benefit as I got mixed results. Those mixed results were a combination of getting the OpenLDAP service to start from the command line (after tweaking some command line arguments to the "slapd" exe by adding a reference to the config file) to the service no longer starting thereafter. When the service would no longer start, I got the dreaded "slapd starting" message in the console whereupon the service would do little else. According to Google searches, the solution appeared to be to "download a later version of OpenLDAP" which clearly wasn't an option as I needed to use the Oracle implementation of OpenLDAP.&lt;br /&gt;&lt;br /&gt;At this point I figured that a re-install was probably on the cards so I uninstalled EPM, deleted the directory into which it had been installed and then reinstalled the EPM software. Guess what... The OpenLDAP service started! oooOOOOOooooo. So a quick config of the services and... D'OH! still no joy! None of the services were able to register with Shared Services. Grumble, grumble, grumble. What now?&lt;br /&gt;&lt;br /&gt;Even more debugging and looking at the Shared Service log files showed messages such as "Native Directory is not reachable. Attempting to re-connect" with references to the server's hostname and a port number of 28089. This seemed to indicate that services were attempting to connect to OpenLDAP on port 28089 and couldn't get through. Further investigations showed that OpenLDAP does not use that port number by default, so it needs to be set at startup.&lt;br /&gt;&lt;br /&gt;Now that's where the fun and games started. Rather than go through all the possible places where they can be set depending on which article you read (which I unfortunately tried), I'll just tell you the right place. It would appear (and I'm guessing here) that the installation of EPM on Windows Server 2008 does not install some much needed registry entries. A colleague of mine installed EPM on Windows XP and it all went well. A quick check of the registry on that machine confirmed that this is what was missing. So...&lt;br /&gt;&lt;br /&gt;What you need to do, is to ensure that the following registry entries (and structure) exists in the registry:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\OpenLDAP\Parameters]&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;with keys:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;ConfigFile      PathToOpenLDAPDirectory&lt;pathtoopenldapdirectory&gt;\slapd.conf&lt;/pathtoopenldapdirectory&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;DebugLevel      0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Urls                   ldap://:28089&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Note that the "ConfigFile" and "Urls" parameters are String settings whereas "DebugLevel" is a DWORD32&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And that's it. A restart of the OpenLDAP service and Shared Services service meant that I could register all the other Hyperion services. The "Urls" parameter is the main setting, as that dictates that OpenLDAP is to listen on port 28089 which is what is required by the rest of the Hyperion services.&lt;br /&gt;&lt;br /&gt;It may also be worth noting that a quick glance at the default &lt;span style="font-family:courier new;"&gt;slapd.conf&lt;/span&gt; file supplied by Oracle lists that a "pid" file and "arg" file be created in the ".../var/run" directory. Clearly a *nix setting but rather amusingly there is no "run" directory under the "var" directory in the Windows structure. If you create it, those files will be created. Also, it may well be worth you adding in an entry for the creation of a logfile. I added an entry in the "slapd.conf" file, immediately below the entries for the "run" and "arg" files to do this. The key looks like:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;logfile    &lt;pathtoopenldapdirectory\log\slapd.log&gt;&lt;/pathtoopenldapdirectory\log\slapd.log&gt;&lt;/span&gt;   &lt;span style="font-family:courier new;"&gt;PathToOpenLDAPDirectory\logs\slapd.log&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To get logging to appear in this file you will need to change the value in the registry entry "DebugLevel" created earlier to a value other than zero. The number 4 is probably a good value to go for or 1 if you wish to debug issues.&lt;br /&gt;&lt;br /&gt;And there you have it. I hope that this helps others to have more time to do things other than the configuration of EPM.&lt;br /&gt;&lt;br /&gt;Good luck.&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-9149177002542770911?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/r55g-a1lzpI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/9149177002542770911/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2008/10/hyperion-epm-on-windows-server-2008.html#comment-form" title="15 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/9149177002542770911?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/9149177002542770911?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/r55g-a1lzpI/hyperion-epm-on-windows-server-2008.html" title="Hyperion EPM on Windows Server 2008" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>15</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2008/10/hyperion-epm-on-windows-server-2008.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUIGRH4ycCp7ImA9WxZbFk0.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-2944356730565174114</id><published>2008-04-19T08:53:00.008+01:00</published><updated>2008-04-19T13:18:45.098+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-19T13:18:45.098+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ProClarity" /><category scheme="http://www.blogger.com/atom/ns#" term="custom SSIS task" /><title>The ProClarity API - Programmatic changes to ProClarity briefing books</title><content type="html">We have a client who is using Analysis Services 2000 and ProClarity Analytics Server 6.3 in order to provide balance sheet and financial line information to their business. The system that I designed had to be able to aggregate financial data up a customer hierarchy but be able to aggregate the data into parents as they stood at the time the data was loaded and against the current parent. (i.e. A slowly changing dimension.) However, this dimension consists of  over 1.5 million members and there are effectively two versions of this in the database.&lt;br /&gt;&lt;br /&gt;Now this on its own is fine-ish, in that with the 3GB switch enabled and some tweaks to the cleaner thread interval the AS solution is stable and performs reasonably well. However, the original requirement did not specify security on these dimensions. As you can guess, there is now a requirement to place security on these dimensions, partially to limit access to the data but more so to provide a way for a given user's reports to open, defaulted to the customers for which they are responsible.&lt;br /&gt;&lt;br /&gt;Now trying to add security using a "security cube" isn't really conducive to performance and adding 440 roles to AS, each with a different security context, isn't really good for maintenance or memory. (i.e. Think replica dimensions.) So, what else?&lt;br /&gt;&lt;br /&gt;Well, as an approach, I wondered if it is possible to take a template ProClarity briefing book located in a PAS Store, load it and customise it for a given user and write it back to the PAS store. From previous experiences I know that just updating the XML in the PAS database for a given briefing book and pages causes problems down the line, to the point that they may no longer work. So how else? Can you make programmatic changes? I know that there is an API for ProClarity but the documentation is all for VB etc. and not .Net.&lt;br /&gt;&lt;br /&gt;In the end I decided to give it a try and started to write an application that would retrieve a result set from a database specifying the template book and pages etc. that are to be customised and the customisations to be made. It also specifies the PAS store into which the book should be ultimately published and security assignments for the new book.&lt;br /&gt;&lt;br /&gt;After contacting Microsoft on TechNet for some hints and tips (whose responses are pretty quick and impressive actually) I was on my way. See &lt;a href="http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2723139&amp;amp;SiteID=17"&gt;Hints and Tips&lt;/a&gt; for that thread.&lt;br /&gt;&lt;br /&gt;The essentials to know, when using C#, are effectively as follows:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;In order to have a briefing book loaded within a ProClarity application in memory, use the &lt;span style="color: rgb(51, 204, 255);"&gt;KProClarityClass&lt;/span&gt;.StartupBook method.&lt;/li&gt;&lt;li&gt;Once you have a &lt;span style="color: rgb(51, 204, 255);"&gt;KProClarityClass&lt;/span&gt; object, use the following objects, properties or methods as shown below...&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;Application (Object)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;CurrentView (Property)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;PageCtrl (Object)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;KPCommand (Object)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;GetAxisMemberSet (Method)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;    |&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;KMemberSet&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As an example, use the &lt;span style="color: rgb(51, 204, 255);"&gt;KProClarityClass&lt;/span&gt;'s Application property to retrieve a reference to the &lt;span style="color: rgb(51, 204, 255);"&gt;Application&lt;/span&gt; object. Now use the Application object's CurrentView property to  retrieve a reference to the the &lt;span style="color: rgb(51, 204, 255);"&gt;ICurrentView&lt;/span&gt; interface etc. etc.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;If you make any changes to a &lt;span style="color: rgb(51, 204, 255);"&gt;KMemberSet&lt;/span&gt;, you must use that object's associated &lt;span style="color: rgb(51, 204, 255);"&gt;KCommand&lt;/span&gt; object's execute method in order update all associated  entities within the  ProClarity object model.&lt;/li&gt;&lt;li&gt;If you copy elements etc. be sure to update the copied element's ID otherwise you will get errors when trying to publish the briefing book. (i.e. You will have two elements with the same ID which understandably is not allowed.) To do this, set the ID for the given element to: &lt;span style="color: rgb(204, 0, 0);"&gt;"{00000000-0000-0000-0000-000000000000}"&lt;/span&gt;&lt;/li&gt;&lt;li&gt;In order to commit changes you have made to a given briefing book page, you have to copy the "page" within the book, using the &lt;span style="color: rgb(51, 204, 255);"&gt;CurrentView&lt;/span&gt;'s AddPageToBook method and then delete the original page. Please don't shout at me, I know, that sucks but that's just how it is okay?&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;In the end I changed my application to run as a custom SSIS task and to be multi-threaded using a blocking-queue in order to hand out template briefing books for updates to consumer threads etc. That all seemed to work although I did experience exceptions when running the task in debug mode. As can be seen by the following thread with Microsoft &lt;a href="http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2967022&amp;amp;SiteID=17"&gt;here&lt;/a&gt;, this was related to my code not being aware of the COM aspects of the ProClarity API.&lt;br /&gt;&lt;br /&gt;All in all it was quite fun to develop, creating mini-caches for PStore connections etc. and to implement a solution that runs within SSIS. I added in the ability to set properties such as the number of threads to use and the ability to set the table and column names that store the relevant updates to be made.&lt;br /&gt;&lt;br /&gt;Using simple test cases it appears to work quite nicely. Reports remain static, such that reports with both grids, totals and graphs etc. retain that layout when the member selections are changed. The task allows the ability to either update members by axis or to simply replace the MDX for the report. (Actually you could replace the MDX for a report and then customise the member selection immediately thereafter if you so wished but why?)&lt;br /&gt;&lt;br /&gt;Before it's a finished beta v0.0.0.0.0.0.1 "product" (Oracle style versioning there) the task needs to accommodate pages within nested folders (i.e. currently only handles pages at the root or one level below) and to complete the security aspect. I also need to normalise the table structures that store the updates to be made against the template briefing book etc.&lt;br /&gt;&lt;br /&gt;Anyhoo, if anyone out there is interested in using this please add a comment to this blog and I'll see if I can add it to our company's website for download. That naturally assumes anyone actually reads my blog...&lt;div class="blogger-post-footer"&gt;&lt;a href="http://feedburner.google.com/fb/a/mailverify?uri=BiLog&amp;amp;loc=en_US"&gt;Subscribe to BI Log by Email&lt;/a&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6334481233407743503-2944356730565174114?l=bi-logger.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/BiLog/~4/-sMvz7Ssabs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://bi-logger.blogspot.com/feeds/2944356730565174114/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://bi-logger.blogspot.com/2008/04/programmatic-changes-to-proclarity.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/2944356730565174114?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6334481233407743503/posts/default/2944356730565174114?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BiLog/~3/-sMvz7Ssabs/programmatic-changes-to-proclarity.html" title="The ProClarity API - Programmatic changes to ProClarity briefing books" /><author><name>Philip Stephenson</name><uri>http://www.blogger.com/profile/12268504284150608108</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="11052701608683583392" /></author><thr:total>3</thr:total><feedburner:origLink>http://bi-logger.blogspot.com/2008/04/programmatic-changes-to-proclarity.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkABQXg8fyp7ImA9WB9aEUQ.&quot;"><id>tag:blogger.com,1999:blog-6334481233407743503.post-6418583785195586201</id><published>2007-12-04T17:01:00.000Z</published><updated>2008-01-01T12:32:30.677Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-01T12:32:30.677Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Oracle 11g Installation" /><title>Oracle 11g on Oracle Linux</title><content type="html">&lt;span style="font-weight: bold;font-size:130%;" &gt;Intro&lt;/span&gt;&lt;br /&gt;So here's the thing...&lt;br /&gt;&lt;br /&gt;I decided to have a more detailed look at Oracle 11g. I like the Oracle relational databases, really I do. They are a mature, stable, scalable database which is feature rich. It can run on Linux, Unix, Windows and even a Mac if you want. However, my focus in this blog is the installation of the database on Linux. Oracle's own in fact...&lt;br /&gt;&lt;br /&gt;So Oracle offer a "distro" of Linux. Sounds good as a concept, Oracle offering an OS on which you can install their database and all. However, if you are a newbie to Linux and/or Oracle you gonna need to set aside quite a bit of time for this. (By quite a bit, read: "a lot!")&lt;br /&gt;
