<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3560362051436279973</id><updated>2024-08-28T18:07:12.271-07:00</updated><category term="SSIS"/><category term="Interview"/><category term="er"/><title type='text'>Business Intelligence with SQL Server &amp;amp; ME</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>33</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-5661372879596727298</id><published>2011-08-07T08:42:00.001-07:00</published><updated>2011-08-07T11:04:08.605-07:00</updated><title type='text'>Setup Date Dimension</title><content type='html'>&lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;You cannot think of business intelligence without date dimension and it is so much so that all our measures mostly spins around date dimension for date/time slicing, YTD, MTD, Month to Month comparison and goes on. In my current assignment I had to build date dimension and that’s when I thought of checking with the BI core group in my company. I got plenty of replies from the group. However I was looking for something which is very easy to understand and implement and thinking so I built one date dimension. Note that in my post I have not kept attributes for fiscal year but if you need to, you would merely have to add bunch of attributes to store fiscal month, quarter etc. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;I am straight away jumping into the script. We need 4 scripts as explained below - &lt;/font&gt;&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;Date dimension table. Name of the table is [OS_Date_Dimension].&lt;/font&gt;&lt;/li&gt; &lt;li&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;Stored procedure to populate date dimension table.&lt;/font&gt;&lt;/li&gt; &lt;li&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;Script to populate your fact with UNKNOWN time member if lookup does not find one key in the date dimension.&lt;/font&gt;&lt;/li&gt; &lt;li&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;Call stored procedure to fill date table.&lt;/font&gt;&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;&lt;strong&gt;Date dimension table. Name of the table is [OS_Date_Dimension]&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;TABLE&lt;/span&gt; [dbo].[Os_Dim_Date](&lt;br&gt;    --Keys&lt;br&gt;    [DateKey] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;PRIMARY&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;KEY&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;CLUSTERED&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,    --20110101&lt;br&gt;    [AlternateDateKey] [nvarchar](10) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,        --2001-07-01&lt;br&gt;    [CalenderDate] [datetime] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --2000-01-01 00:00:00.000&lt;br&gt;    &lt;br&gt;    --&lt;span style=&quot;color: #0000ff&quot;&gt;Day&lt;/span&gt;&lt;br&gt;    [DayOfWeek] [nvarchar](9) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --Sunday&lt;br&gt;    [ShortDayOfWeek] [nvarchar](3) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,        --Sun&lt;br&gt;    [DayNumOfYear] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                    --1, 2, 3..365&lt;br&gt;    [DayNumOfQuarter] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --1, 2, 3..90&lt;br&gt;    [DayNumOfMonth] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                    --1, 2, 3..31&lt;br&gt;    [DayNumOfWeek] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                    --1, 2, 3..7&lt;br&gt;    &lt;br&gt;    --Week&lt;br&gt;    [WeekName] [nvarchar](20) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --2000-Week-1&lt;br&gt;    [WeekNumOfYear] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                    --1, 2, 3..49&lt;br&gt;    [WeekNumOfQuarter] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --1, 2, 3..14&lt;br&gt;    [WeekNumOfMonth] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --1, 2, 3..6&lt;br&gt;    &lt;br&gt;    --&lt;span style=&quot;color: #0000ff&quot;&gt;Month&lt;/span&gt;&lt;br&gt;    [MonthName] [nvarchar](20) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,            --January 2001&lt;br&gt;    [MonthShortName] [nvarchar](6) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,        --Jan&lt;br&gt;    [MonthNumOfYear] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --1, 2..12&lt;br&gt;    [MonthNumOfQuarter] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --1, 2 &lt;span style=&quot;color: #0000ff&quot;&gt;and&lt;/span&gt; 3&lt;br&gt;    &lt;br&gt;    --Quarter&lt;br&gt;    [QuarterName] [nvarchar](10) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,            --2000 Q1&lt;br&gt;    [QuarterShortName] [nvarchar](5) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,        --Q1&lt;br&gt;    [Quarter] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                        --1,2,3 &lt;span style=&quot;color: #0000ff&quot;&gt;and&lt;/span&gt; 4&lt;br&gt;        &lt;br&gt;    --&lt;span style=&quot;color: #0000ff&quot;&gt;Year&lt;/span&gt;&lt;br&gt;    [YearName] [nvarchar](7) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --2011&lt;br&gt;    [&lt;span style=&quot;color: #0000ff&quot;&gt;Year&lt;/span&gt;] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                            --2011&lt;br&gt;        &lt;br&gt;    --Additional&lt;br&gt;    [SemiMonth] [nvarchar](50) &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                --SemiMonthP1 January 2011&lt;br&gt;    [Semester] [&lt;span style=&quot;color: #0000ff&quot;&gt;int&lt;/span&gt;] &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;,                        --1 &lt;span style=&quot;color: #0000ff&quot;&gt;and&lt;/span&gt; 2&lt;br&gt;    [SemesterName] [nvarchar](11) &lt;span style=&quot;color: #0000ff&quot;&gt;NOT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;NULL&lt;/span&gt;            --H1 CY 2001&lt;br&gt;)&lt;br&gt;GO&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;&lt;strong&gt;Stored procedure to populate date dimension table&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;--Stored &lt;span style=&quot;color: #0000ff&quot;&gt;procedure&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;to&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;create&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt; dimension &lt;span style=&quot;color: #0000ff&quot;&gt;table&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;CREATE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;PROCEDURE&lt;/span&gt; [dbo].[Os_Populate_Date_Dim]&lt;br&gt;(&lt;br&gt;  @FIRST_DATE       DATETIME,&lt;br&gt;  @LAST_DATE        DATETIME&lt;br&gt;)&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;BEGIN&lt;/span&gt;&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;WITH&lt;/span&gt; TE_Os_Dim_Date &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; &lt;br&gt;    ( &lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Cast&lt;/span&gt; (@FIRST_DATE &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; DateTime) &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;        --&lt;span style=&quot;color: #0000ff&quot;&gt;Start&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt; &lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;UNION&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;ALL&lt;/span&gt; &lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt; + 1 &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; TE_Os_Dim_Date &lt;br&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;WHERE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt; + 1 &amp;lt; = @LAST_DATE                --&lt;span style=&quot;color: #0000ff&quot;&gt;End&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt; &lt;br&gt;    ) &lt;br&gt;    INSERT &lt;span style=&quot;color: #0000ff&quot;&gt;INTO&lt;/span&gt; [dbo].[Os_Dim_Date] (&lt;br&gt;         [DateKey]&lt;br&gt;        ,[AlternateDateKey]&lt;br&gt;        ,[CalenderDate]&lt;br&gt;        ,[DayOfWeek]&lt;br&gt;        ,[ShortDayOfWeek]&lt;br&gt;        ,[DayNumOfYear]&lt;br&gt;        ,[DayNumOfQuarter]&lt;br&gt;        ,[DayNumOfMonth]&lt;br&gt;        ,[DayNumOfWeek]&lt;br&gt;        ,[WeekName]&lt;br&gt;        ,[WeekNumOfYear]&lt;br&gt;        ,[WeekNumOfQuarter]&lt;br&gt;        ,[WeekNumOfMonth]&lt;br&gt;        ,[MonthName]&lt;br&gt;        ,[MonthShortName]&lt;br&gt;        ,[MonthNumOfYear]&lt;br&gt;        ,[MonthNumOfQuarter]&lt;br&gt;        ,[QuarterName]&lt;br&gt;        ,[QuarterShortName]&lt;br&gt;        ,[Quarter]&lt;br&gt;        ,[YearName]&lt;br&gt;        ,[&lt;span style=&quot;color: #0000ff&quot;&gt;Year&lt;/span&gt;]&lt;br&gt;        ,[SemiMonth]&lt;br&gt;        ,[Semester]&lt;br&gt;        ,[SemesterName]&lt;br&gt;    )&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;SELECT&lt;/span&gt; &lt;br&gt;        &lt;span style=&quot;color: #0000ff&quot;&gt;CAST&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;CONVERT&lt;/span&gt;(NVARCHAR(30),&lt;span style=&quot;color: #0000ff&quot;&gt;DATE&lt;/span&gt;, 112) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;INT&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; DateKey&lt;br&gt;        ,&lt;span style=&quot;color: #0000ff&quot;&gt;LEFT&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;CAST&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;CONVERT&lt;/span&gt;(NVARCHAR(30),&lt;span style=&quot;color: #0000ff&quot;&gt;DATE&lt;/span&gt;, 120) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt;), 10) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; AlternateDateKey&lt;br&gt;        ,&lt;span style=&quot;color: #0000ff&quot;&gt;DATE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; CalenderDate&lt;br&gt;        &lt;br&gt;        ,DateName (dw, &lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; DayOfWeek&lt;br&gt;        ,&lt;span style=&quot;color: #0000ff&quot;&gt;LEFT&lt;/span&gt; (DateName (dw, &lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;), 3) &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; ShortDayOfWeek&lt;br&gt;        ,DATEPART (DY, &lt;span style=&quot;color: #0000ff&quot;&gt;DATE&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; DayNumOfYear &lt;br&gt;        ,DATEDIFF(DD,DATEADD(QQ,DATEDIFF(QQ,0,&lt;span style=&quot;color: #0000ff&quot;&gt;DATE&lt;/span&gt;),0),&lt;span style=&quot;color: #0000ff&quot;&gt;DATE&lt;/span&gt;)+1 &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; DayNumOfQuarter &lt;br&gt;        ,&lt;span style=&quot;color: #0000ff&quot;&gt;DAY&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;DATE&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; DayNumOfMonth &lt;br&gt;        ,DATEPART (DW, &lt;span style=&quot;color: #0000ff&quot;&gt;DATE&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; DayNumOfWeek &lt;br&gt;        &lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Week &#39;&lt;/span&gt; + &lt;span style=&quot;color: #0000ff&quot;&gt;CAST&lt;/span&gt;(DatePart (wk, &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt;) + &lt;span style=&quot;color: #006080&quot;&gt;&#39; CY &#39;&lt;/span&gt; + &lt;span style=&quot;color: #0000ff&quot;&gt;convert&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;varchar&lt;/span&gt;(4),&lt;span style=&quot;color: #0000ff&quot;&gt;YEAR&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;)) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; WeekName&lt;br&gt;        ,DatePart (wk, &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; WeekNumOfYear &lt;br&gt;        ,datediff(wk,dateadd(qq,datediff(qq,0,&lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;),0),&lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;)+1 &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; WeekNumOfQuarter &lt;br&gt;        ,datediff(wk,dateadd(mm,datediff(mm,0,&lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;),0),&lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;)+1 &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; WeekNumOfMonth &lt;br&gt;&lt;br&gt;        ,DateName (mm, &lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;) + &lt;span style=&quot;color: #006080&quot;&gt;&#39; &#39;&lt;/span&gt; + datename(&lt;span style=&quot;color: #0000ff&quot;&gt;year&lt;/span&gt;,&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; MonthName &lt;br&gt;        ,&lt;span style=&quot;color: #0000ff&quot;&gt;LEFT&lt;/span&gt; ( DateName (mm, &lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;), 3) MonthShortName &lt;br&gt;        ,&lt;span style=&quot;color: #0000ff&quot;&gt;MONTH&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; MonthNumOfYear &lt;br&gt;        ,DateDiff(mm,DateAdd(qq,DateDiff(qq,0,&lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;),0),&lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;)+1 &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; MonthNumOfQuarter &lt;br&gt;        &lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Q&#39;&lt;/span&gt; + datename(quarter,&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) + &lt;span style=&quot;color: #006080&quot;&gt;&#39; CY &#39;&lt;/span&gt; + datename(&lt;span style=&quot;color: #0000ff&quot;&gt;year&lt;/span&gt;,&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; QuarterName&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Q&#39;&lt;/span&gt;+ datename(quarter,&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; QuarterShortName&lt;br&gt;        ,DatePart ( qq, &lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; Quarter &lt;br&gt;        &lt;br&gt;        ,datename(&lt;span style=&quot;color: #0000ff&quot;&gt;year&lt;/span&gt;,&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; YearName&lt;br&gt;        ,&lt;span style=&quot;color: #0000ff&quot;&gt;YEAR&lt;/span&gt; (&lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Year&lt;/span&gt; &lt;br&gt;        &lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;SemiMonthP&#39;&lt;/span&gt; +  &lt;span style=&quot;color: #0000ff&quot;&gt;CASE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;WHEN&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;Day&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &amp;lt;= 15 &lt;span style=&quot;color: #0000ff&quot;&gt;then&lt;/span&gt; &lt;span style=&quot;color: #006080&quot;&gt;&#39;1&#39;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;ELSE&lt;/span&gt; &lt;span style=&quot;color: #006080&quot;&gt;&#39;2&#39;&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;END&lt;/span&gt; + &lt;span style=&quot;color: #006080&quot;&gt;&#39; &#39;&lt;/span&gt; +  DateName (mm, &lt;span style=&quot;color: #0000ff&quot;&gt;date&lt;/span&gt;) + &lt;span style=&quot;color: #006080&quot;&gt;&#39; &#39;&lt;/span&gt; +  datename(&lt;span style=&quot;color: #0000ff&quot;&gt;year&lt;/span&gt;,&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; SemiMonth&lt;br&gt;        ,&lt;span style=&quot;color: #0000ff&quot;&gt;CASE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;WHEN&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;MONTH&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &amp;lt;= 6 &lt;span style=&quot;color: #0000ff&quot;&gt;then&lt;/span&gt; 1 &lt;span style=&quot;color: #0000ff&quot;&gt;ELSE&lt;/span&gt; 2 &lt;span style=&quot;color: #0000ff&quot;&gt;END&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; Semester&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;H&#39;&lt;/span&gt; + &lt;span style=&quot;color: #0000ff&quot;&gt;CAST&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;CASE&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;WHEN&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;MONTH&lt;/span&gt;(&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &amp;lt;= 6 &lt;span style=&quot;color: #0000ff&quot;&gt;then&lt;/span&gt; 1 &lt;span style=&quot;color: #0000ff&quot;&gt;ELSE&lt;/span&gt; 2 &lt;span style=&quot;color: #0000ff&quot;&gt;END&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;VARCHAR&lt;/span&gt;) + &lt;span style=&quot;color: #006080&quot;&gt;&#39; CY &#39;&lt;/span&gt; +  datename(&lt;span style=&quot;color: #0000ff&quot;&gt;year&lt;/span&gt;,&lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt;) &lt;span style=&quot;color: #0000ff&quot;&gt;AS&lt;/span&gt; [SemesterName]&lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;FROM&lt;/span&gt; TE_Os_Dim_Date &lt;br&gt;    &lt;br&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;OPTION&lt;/span&gt; (MAXRECURSION 0)&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;END&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;GO&lt;/span&gt;&lt;br&gt;&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;&lt;strong&gt;Script to populate your fact with UNKNOWN time member if lookup does not find one key in the date dimension&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;--Insert a record &lt;span style=&quot;color: #0000ff&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;unknown&lt;/span&gt; lookup&lt;br&gt;INSERT &lt;span style=&quot;color: #0000ff&quot;&gt;INTO&lt;/span&gt; [dbo].[Os_Dim_Date] (&lt;br&gt;         [DateKey]&lt;br&gt;        ,[AlternateDateKey]&lt;br&gt;        ,[CalenderDate]&lt;br&gt;        ,[DayOfWeek]&lt;br&gt;        ,[ShortDayOfWeek]&lt;br&gt;        ,[DayNumOfYear]&lt;br&gt;        ,[DayNumOfQuarter]&lt;br&gt;        ,[DayNumOfMonth]&lt;br&gt;        ,[DayNumOfWeek]&lt;br&gt;        ,[WeekName]&lt;br&gt;        ,[WeekNumOfYear]&lt;br&gt;        ,[WeekNumOfQuarter]&lt;br&gt;        ,[WeekNumOfMonth]&lt;br&gt;        ,[MonthName]&lt;br&gt;        ,[MonthShortName]&lt;br&gt;        ,[MonthNumOfYear]&lt;br&gt;        ,[MonthNumOfQuarter]&lt;br&gt;        ,[QuarterName]&lt;br&gt;        ,[QuarterShortName]&lt;br&gt;        ,[Quarter]&lt;br&gt;        ,[YearName]&lt;br&gt;        ,[&lt;span style=&quot;color: #0000ff&quot;&gt;Year&lt;/span&gt;]&lt;br&gt;        ,[SemiMonth]&lt;br&gt;        ,[Semester]&lt;br&gt;        ,[SemesterName]&lt;br&gt;    )&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;VALUES&lt;/span&gt;&lt;br&gt;    (&lt;br&gt;         19000101&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;1900-01-01&#39;&lt;/span&gt; &lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;1900-01-01 00:00:00&#39;&lt;/span&gt;&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Unknown&#39;&lt;/span&gt; ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Unk&#39;&lt;/span&gt;, 1, 1 ,1 ,1&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Unknown&#39;&lt;/span&gt;, 1 ,1 ,1&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Unknown&#39;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&#39;Unk&#39;&lt;/span&gt; ,1 ,1&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Unkown&#39;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&#39;Q1&#39;&lt;/span&gt;, 1&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;1900&#39;&lt;/span&gt;, 1900&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Unknown&#39;&lt;/span&gt;, 1&lt;br&gt;        ,&lt;span style=&quot;color: #006080&quot;&gt;&#39;Unknown&#39;&lt;/span&gt;&lt;br&gt;    )&lt;br&gt;GO&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;&lt;strong&gt;Call stored procedure to fill date table&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;&lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;--Populate &lt;span style=&quot;color: #0000ff&quot;&gt;Date&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;from&lt;/span&gt; 2001 &lt;span style=&quot;color: #0000ff&quot;&gt;to&lt;/span&gt; 2020&lt;br&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;EXEC&lt;/span&gt; [dbo].[Os_Populate_Date_Dim] &lt;span style=&quot;color: #006080&quot;&gt;&#39;2001-01-01&#39;&lt;/span&gt;, &lt;span style=&quot;color: #006080&quot;&gt;&#39;2020-12-31&#39;&lt;/span&gt;&lt;br&gt;GO&lt;/pre&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;Now let’s setup dimension attribute key, name and hierarchies in the cube. Your Dimension structure (Hierarchies) and attributes relationship should look like this at the end of the exercise.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-WmW2MCbinOI/Tj7TitDmrxI/AAAAAAAABuw/cgflAuajcKU/s1600-h/image%25255B6%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-2Os1oJlE8DY/Tj7TjCLGIQI/AAAAAAAABu0/vgJJUMEVmFs/image_thumb%25255B4%25255D.png?imgmax=800&quot; width=&quot;644&quot; height=&quot;426&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-Ez0YFLpztt0/Tj7Tjj1QDHI/AAAAAAAABu4/z9wDFmrp5cY/s1600-h/image%25255B10%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-aioD7_hfbCA/Tj7Tj0wUvgI/AAAAAAAABu8/HA9phuzOjWA/image_thumb%25255B6%25255D.png?imgmax=800&quot; width=&quot;644&quot; height=&quot;87&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;Set attribute key and names as illustrated below - &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;table border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;641&quot;&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;161&quot;&gt;&lt;br /&gt;&lt;p align=&quot;center&quot;&gt;&lt;strong&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;Attribute Name&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;224&quot;&gt;&lt;br /&gt;&lt;p align=&quot;center&quot;&gt;&lt;strong&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;KeyColumns Property&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;254&quot;&gt;&lt;br /&gt;&lt;p align=&quot;center&quot;&gt;&lt;strong&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;NameColumn Property&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;161&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;DateKey&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;224&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.DateKey (Integer)&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;254&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.CalenderDate (WChar)&lt;br&gt;&lt;strong&gt;ValueColumn&lt;/strong&gt;: Os_Dim_Date.CalenderDate (WChar)&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;161&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Month Name&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;224&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.Year (Integer)&lt;br&gt;Os_Dim_Date.MonthNumOfYear (Integer)&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;254&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.MonthName (WChar)&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;161&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Quarter&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;224&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.Year (Integer)&lt;br&gt;Os_Dim_Date.Quarter (Integer)&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;254&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.QuarterName (WChar)&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;161&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Year&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;224&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.Year (Integer)&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;254&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.YearName (WChar)&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;161&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Week Name&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;224&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.MonthName (WChar)&lt;br&gt;Os_Dim_Date.WeekNumOfMonth (Integer)&lt;/font&gt;&lt;/td&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;254&quot;&gt;&lt;font size=&quot;1&quot; face=&quot;Verdana&quot;&gt;Os_Dim_Date.WeekName&lt;/font&gt; (WChar)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;Next process dimension and browse Date and Week Hier. Find below the illustrations.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-7biR8NmagJ8/Tj7TkQEybYI/AAAAAAAABvA/euUlAHHK2fs/s1600-h/image%25255B14%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-JxhkbRJXG_k/Tj7Tk0KId6I/AAAAAAAABvE/8Rn4UDtcx1o/image_thumb%25255B8%25255D.png?imgmax=800&quot; width=&quot;610&quot; height=&quot;484&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-QTqQcCuZiTc/Tj7TlOWD1zI/AAAAAAAABvI/bZBbem-FDXI/s1600-h/image%25255B18%25255D.png&quot;&gt;&lt;img style=&quot;background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-0iiT4qBGa0w/Tj7Tl-5gPrI/AAAAAAAABvM/Aljq9lejE74/image_thumb%25255B10%25255D.png?imgmax=800&quot; width=&quot;431&quot; height=&quot;484&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font size=&quot;2&quot; face=&quot;Verdana&quot;&gt;You may need more attributes related to fiscal year, holidays etc. which you should be able to add easily by extending table and stored procedure. Hope this helps. &lt;/font&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/5661372879596727298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/08/setup-date-dimension.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/5661372879596727298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/5661372879596727298'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/08/setup-date-dimension.html' title='Setup Date Dimension'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-2Os1oJlE8DY/Tj7TjCLGIQI/AAAAAAAABu0/vgJJUMEVmFs/s72-c/image_thumb%25255B4%25255D.png?imgmax=800" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-4166995391742317922</id><published>2011-06-16T08:46:00.001-07:00</published><updated>2011-06-16T08:47:34.317-07:00</updated><title type='text'>Reports using Cube or Relational Database..some points to consider</title><content type='html'>&lt;p&gt;&lt;a name=&quot;OLE_LINK1&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;We should try and use cube and not relational database for building SSRS reports. Here are the some of the advantages that cube has over relational database – &lt;/font&gt;&lt;/a&gt; &lt;ol&gt; &lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Cube is much faster source for canned and ad-hoc reporting. Reason, aggregated and processed data is stored in cube database (of course if implemented using MOLAP).&lt;/font&gt; &lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Information or the measures are organized in a way which is easy to build excel pivot table which business user can easily understand. &lt;/font&gt; &lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;It is very easy to implement hierarchy and drill down using cube and MDX compared with Relational database and SQL queries.&lt;/font&gt; &lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;With cube we can use power of MDX to build complex reports, like YTD, Running total, Semi additive measure, trend, parallel period etc.&lt;/font&gt; &lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Calculated measures can be stored in the cube and can be used by developer to build report or business user browsing them directly using any client application or excel. Other hand we never store calculated column in the relational database table.&lt;/font&gt; &lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Even ad-hoc reporting becomes handy and easy with cube as some of the client software like ProClarity only work with cube.&lt;/font&gt; &lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Using cube we can easily get different view of a measure using linked dimensions. Say spend by vendor, location etc.&lt;/font&gt; &lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;However not all the report should be build using the cube. For example, detail reports where we want to view detail data as they were pulled from the source system, we should use SQL report. In this case we are not making use of aggregated data from the cube and SQL query can returns the detail rows much master than MDX.&lt;/font&gt;&lt;/li&gt;&lt;/ol&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/4166995391742317922/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/ssrs-using-cube-or-relational.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/4166995391742317922'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/4166995391742317922'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/ssrs-using-cube-or-relational.html' title='Reports using Cube or Relational Database..some points to consider'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-6811661446396086256</id><published>2011-06-06T16:06:00.001-07:00</published><updated>2011-06-06T16:07:41.122-07:00</updated><title type='text'>SSAS NULL value default behavior</title><content type='html'>&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;One of my direct reports asked me last week about how SSAS handles NULL measure if present in the fact table. I think he encountered this in one of his business intelligence job interview :).&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;I thought let’s write a small post about the topic and this way others will also be get benefited plus I don’t have to explain it to him separately.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;I have a sales fact table which is linked to product, measure type, organization and time dimensions. Here is part of the fact table - &lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://lh6.ggpht.com/-cALWuODWtas/Te1dgjzuNSI/AAAAAAAABlU/b89o45j-tfI/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; color=&quot;#222222&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;174&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-wc25GWnAsSg/Te1dhN3_VtI/AAAAAAAABlY/1j1tDnDkc_I/image_thumb%25255B2%25255D.png?imgmax=800&quot; width=&quot;579&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&amp;nbsp;&lt;br&gt;As you see we have got plenty of NULL value under plan and forecast measures. We will stick to Actual and Plan measures for our discussion. Let’s browse the cube and put this in perspective for you to see how SSAS treat NULL measure value. Any guess at this point?&lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://lh6.ggpht.com/-nA7sqdPtR4o/Te1dhmSGe0I/AAAAAAAABlc/7FLIjpryZCE/s1600-h/image%25255B8%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; color=&quot;#222222&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;135&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-nwxchwP5eMY/Te1dhwXrWlI/AAAAAAAABlg/6Nc_qQ9bU_U/image_thumb%25255B4%25255D.png?imgmax=800&quot; width=&quot;541&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&amp;nbsp;&lt;br&gt;I have filter products with PRODUCT_SK in (48, 55 and 56) where we have NULL under plan but has got some Actual sales value. This is bit strange with SSAS which replaces NULL with 0 by default, meaning does not preserve NULL. However, this may mislead the business and you may want to preserve NULL for all intense purposes. In this case it is just that business has not decided on the plan, forecast etc for certain products does not necessarily mean that plan amount is 0.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Lets get straight to the SSAS measure properties and there is a way to preserver NULL value. Go to the cube solution, select you measure and change &lt;strong&gt;NullProcessing &lt;/strong&gt;property under &lt;strong&gt;Source &lt;/strong&gt;from &lt;strong&gt;Automatic &lt;/strong&gt;to &lt;strong&gt;Preserve&lt;/strong&gt;. Next process the cube and reconnect to OLAP db to refresh. &lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://lh6.ggpht.com/-A8GDF9h2DMM/Te1diYKDSBI/AAAAAAAABlk/0u0eklVHVl4/s1600-h/image%25255B12%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; color=&quot;#222222&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;327&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-ismM4PNrVHk/Te1di4aDqAI/AAAAAAAABlo/bu142nHPRlk/image_thumb%25255B6%25255D.png?imgmax=800&quot; width=&quot;424&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&amp;nbsp;&lt;br&gt;Here is what I mean. We don’t see 0 anymore. You should carefully decide whether or not you want to keep NULL and make use of this property.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-9ECsrdYWK8I/Te1djOaydLI/AAAAAAAABls/YESW4liqdNU/s1600-h/image%25255B16%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; color=&quot;#222222&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;121&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-4hO7cXRuQQQ/Te1dkfLX9PI/AAAAAAAABlw/ITG8_v7Eua0/image_thumb%25255B8%25255D.png?imgmax=800&quot; width=&quot;469&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;em&gt;Please leave any feedback or suggestions you have!&lt;/em&gt;&lt;/font&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/6811661446396086256/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/ssas-automatic-null-value-behavior.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6811661446396086256'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6811661446396086256'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/ssas-automatic-null-value-behavior.html' title='SSAS NULL value default behavior'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-wc25GWnAsSg/Te1dhN3_VtI/AAAAAAAABlY/1j1tDnDkc_I/s72-c/image_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-6680268017836320775</id><published>2011-06-06T12:20:00.001-07:00</published><updated>2011-06-06T12:20:45.388-07:00</updated><title type='text'>NON EMPTY vs NONEMPTY(&amp;lt;set&amp;gt;, &amp;lt;set&amp;gt;)</title><content type='html'>&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;To remove NULL values from the query output we use NON EMPTY or NONEMPTY functions. There is small difference between NON EMPTY and NONEMPTY function, I am providing difference with examples through this post. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Let’s run following MDX query - &lt;/font&gt;&lt;/p&gt; &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;562&quot; border=&quot;1&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;560&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    [Measures].[INV PROD SALES ACTUAL],&lt;br /&gt;    [Measures].[LEAD TO CALL PRODUCT ACTUAL]} &lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;/span&gt;,&lt;br /&gt;{&lt;br /&gt;    [MEASURE TYPE].[MEASURE TYPE].&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: maroon&quot;&gt;Children    &lt;br /&gt;&lt;/span&gt;} &lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;ON ROWS&lt;br /&gt;FROM &lt;/span&gt;[YOUR CUBE]&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Result of the above query. As you see there are plenty of NULL values we got for the MEASURE TYPE set.&lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://lh5.ggpht.com/-mABhe_F0_HU/Te0oek8FG4I/AAAAAAAABkw/I-k1MCEblvc/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;221&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-zftmDsVmfTQ/Te0ofZqemJI/AAAAAAAABk0/DVvV6n11lW8/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;441&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Now let’s use NON EMPTY on the set, here is the changed query - &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; border=&quot;1&quot;&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    [Measures].[INV PROD SALES ACTUAL],&lt;br /&gt;    [Measures].[LEAD TO CALL PRODUCT ACTUAL]} &lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;/span&gt;,&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;strong&gt;NON EMPTY&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    [MEASURE TYPE].[MEASURE TYPE].&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: maroon&quot;&gt;Children    &lt;br /&gt;&lt;/span&gt;} &lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;ON ROWS&lt;br /&gt;FROM &lt;/span&gt;[YOUR CUBE]&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Here is the output with NON EMPTY - &lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://lh4.ggpht.com/-f4xkZJi9xX4/Te0of7Rz_3I/AAAAAAAABk4/xgaNji967LE/s1600-h/image%25255B10%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;116&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-lbPOYGEj3X4/Te0ogQF1l-I/AAAAAAAABk8/TnhrxuCKpmU/image_thumb%25255B4%25255D.png?imgmax=800&quot; width=&quot;409&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;As you see now wherever we had NULL for both the measure those measure types have been filtered (meaning removed). So NON EMPTY works on the overall result, meaning after set get first evaluated, all the tuples with NULL values for all the measures, are removed.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;On the other hand NONEMPTY() takes 2 sets as parameters. Its uses tuples of the first set and filtered out all empty tuples based on the cross product with second set. Meaning behind the scene what happens is, NONEMPTY is evaluated when the set defining the rows axis is evaluated. Let’s analyze the query - &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;557&quot; border=&quot;1&quot;&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;555&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;NON EMPTY&lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    [Measures].[INV PROD SALES ACTUAL],&lt;br /&gt;    [Measures].[LEAD TO CALL PRODUCT ACTUAL]} &lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;/span&gt;,&lt;br /&gt;{&lt;br /&gt;    &lt;span style=&quot;color: maroon&quot;&gt;&lt;strong&gt;NONEMPTY&lt;/strong&gt;&lt;/span&gt;([MEASURE TYPE].[MEASURE TYPE].&lt;span style=&quot;color: maroon&quot;&gt;Children&lt;/span&gt;,&lt;br /&gt;    [Measures].[LEAD TO CALL PRODUCT ACTUAL])    &lt;br /&gt;} &lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;ON ROWS&lt;br /&gt;FROM &lt;/span&gt;[YOUR CUBE]&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Before we get into the result, let’s analyze the above query. As we discussed above NONEMPTY will be evaluated with LEAD TO CALL PRODUCT ACTUAL measure in the ROW axis first and will bring all the MEASURE TYPE tuples wherever we have value for LEAD TO CALL PRODUCT ACTUAL measure. Also note that if we don’t pass any measure in the NONEMPTY it takes default measure and filter non empty value for the set. From the first query output I am graying out the cells that we don’t expect in the query result.&lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://lh6.ggpht.com/-to2xY5Q0-VE/Te0og4TN8NI/AAAAAAAABlA/6BHplL4_USQ/s1600-h/image%25255B14%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;259&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-pKfhmtzlO8o/Te0ohjheSiI/AAAAAAAABlE/l9rCw98vdzo/image_thumb%25255B6%25255D.png?imgmax=800&quot; width=&quot;518&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Here is the above query output. &lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://lh4.ggpht.com/-fstAmW74NkE/Te0oh5MPA2I/AAAAAAAABlI/i6ZA7xdqmHM/s1600-h/image%25255B19%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;a href=&quot;http://lh4.ggpht.com/-fstAmW74NkE/Te0oh5MPA2I/AAAAAAAABlM/-5Xwwj3kci4/s1600-h/image%25255B20%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;91&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-xOUgDXO2aSw/Te0ojByRIzI/AAAAAAAABlQ/kKCEsRFWx5Y/image_thumb%25255B10%25255D.png?imgmax=800&quot; width=&quot;252&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&amp;nbsp;&lt;br&gt;NONEMPTY should be used to get rid of empty tuples in the set for specified measure and it helps improve query performance. Specially when you cross join the dimension(s) members you should always consider NONEMPTY. Leave your comments..see you back soon!&lt;/font&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/6680268017836320775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/non-empty-vs-nonempty.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6680268017836320775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6680268017836320775'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/non-empty-vs-nonempty.html' title='NON EMPTY vs NONEMPTY(&amp;lt;set&amp;gt;, &amp;lt;set&amp;gt;)'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-zftmDsVmfTQ/Te0ofZqemJI/AAAAAAAABk0/DVvV6n11lW8/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-8986964045052045931</id><published>2011-06-03T14:28:00.001-07:00</published><updated>2011-06-06T07:58:07.315-07:00</updated><title type='text'>SCD Type – 2 using MERGE and Output $action</title><content type='html'>&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;In this article we will talk about achieving SCD behavior using Sql MERGE statement. MERGE join works well based on join condition with source table and through available condition you can have INSERT, UPDATE or DELETE actions. Primarily what it does is that it compare key value of target with source table and perform different operations specified like WHEN MATCHED, WHEN NOT MATCHED etc.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;The main focus of this post is to make use of &lt;strong&gt;$action &lt;/strong&gt;virtual output column when we execute MERGE sql and decide as in whether INSERT or UPDATE has been performed on the source. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Let get to the business area and see these in action.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Create a table first and populate some records, or you can use the same table from my previous post.&lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://takeatourtobi.blogspot.com/2011/06/delete-and-truncate-behavior.html&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;http://takeatourtobi.blogspot.com/2011/06/delete-and-truncate-behavior.html&lt;/font&gt;&lt;/a&gt;&lt;/p&gt; &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; border=&quot;1&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;--Create student table&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CREATE TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;    &lt;/span&gt;ID &lt;span style=&quot;color: blue&quot;&gt;INT&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;br /&gt;    &lt;/span&gt;NAME &lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;100&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;) NULL,&lt;br /&gt;    &lt;/span&gt;AGE &lt;span style=&quot;color: blue&quot;&gt;INT &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;NULL,&lt;br /&gt;    &lt;/span&gt;ACTIVE &lt;span style=&quot;color: blue&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;1&lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;)&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;--Insert some records&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;INSERT INTO &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT] &lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;VALUES&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Mark&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;32&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;2&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Elaine&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;31&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;3&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Elton&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;33&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;4&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;John&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;40&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;5&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Smith&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;30&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Select student table. This is our target table - &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-jKE4a10Jpq4/TelSFMNGWUI/AAAAAAAABkg/lE88y8zOnFc/s1600-h/image%25255B8%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;140&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-WNCzp22f9wI/TelSFnemy5I/AAAAAAAABkk/TyFso5Br-W0/image_thumb%25255B4%25255D.png?imgmax=800&quot; width=&quot;313&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Create another table which will have the delta which we have to apply on student table. Note that we will be using ID column value as key to decide whether or not student already exists. Here is the delta table script and rows..&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;400&quot; border=&quot;1&quot;&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;400&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;CREATE TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STG_STUDENT]&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;    &lt;/span&gt;ID &lt;span style=&quot;color: blue&quot;&gt;INT PRIMARY KEY&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;br /&gt;    &lt;/span&gt;NAME &lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;100&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;) NULL,&lt;br /&gt;    &lt;/span&gt;AGE &lt;span style=&quot;color: blue&quot;&gt;INT &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;NULL&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;INSERT INTO &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STG_STUDENT] &lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;VALUES&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Mark Luther&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;42&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;2&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Elaine Wang&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;41&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;6&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Elton B&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;22&lt;span style=&quot;color: gray&quot;&gt;)&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Since we are doing SCD Type – 2, this is what will be the scenarios - &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;If get a new student (New ID value), we will insert into the target table and set Active = ‘Y’&lt;/font&gt; &lt;br /&gt;&lt;li&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;If get an existing student, we will insert it to the target table with Active = ‘Y’ and set Active = ‘N’ for all other records of that student. Meaning, at a any given point in time, we should have only one active record for each student.&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;As said earlier idea here is to make use of &lt;strong&gt;OUTPUT $action&lt;/strong&gt; to retrieve the records that got updated and once we have this list, we can insert it finally and set flag to ‘N’ for all other records for a student. &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Here is the final SQL statement and target table output.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;547&quot; border=&quot;1&quot;&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;545&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;INSERT INTO &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]    &lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;AGE&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39; &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;FROM&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;MERGE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT] &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;TRG&lt;br /&gt;        &lt;span style=&quot;color: blue&quot;&gt;USING &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STG_STUDENT] &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;SRC&lt;br /&gt;            &lt;span style=&quot;color: blue&quot;&gt;ON &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;SRC&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;ID &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;TRG&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;ID &lt;span style=&quot;color: gray&quot;&gt;AND &lt;/span&gt;TRG&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;ACTIVE &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WHEN &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;NOT MATCHED &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;THEN &lt;br /&gt;            INSERT VALUES &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;SRC&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;SRC&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;SRC&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;AGE&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WHEN &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;MATCHED &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;THEN &lt;br /&gt;            UPDATE SET &lt;/span&gt;TRG&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;ACTIVE &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;N&#39;&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;OUTPUT &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;$action&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;SRC&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;SRC&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;SRC&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;AGE&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;DELTA &lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;action&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;Name&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;Age&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WHERE action &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Update&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-zkNoTtXv6f4/TelSF9k3Y-I/AAAAAAAABko/1gf8W4T6l0M/s1600-h/image%25255B12%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;193&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-0c1BGWRZHSo/TelSGTdlbzI/AAAAAAAABks/GNiSCMcwcok/image_thumb%25255B6%25255D.png?imgmax=800&quot; width=&quot;371&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;As you see, we had 2 existing students in the delta table for which active is set to ‘N’ and 2 new entries have been created in the table with Active = ‘Y’. There were one new student (ID = 6), which got inserted into the table. This way we can achieve SCD Type – 2 using MERGE SQL. Please leave your comments/feedback.&lt;/font&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/8986964045052045931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/scd-type-2-using-merge-and-output.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/8986964045052045931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/8986964045052045931'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/scd-type-2-using-merge-and-output.html' title='SCD Type – 2 using MERGE and Output $action'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-WNCzp22f9wI/TelSFnemy5I/AAAAAAAABkk/TyFso5Br-W0/s72-c/image_thumb%25255B4%25255D.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-5322218478544223702</id><published>2011-06-03T08:26:00.001-07:00</published><updated>2011-06-03T08:26:11.829-07:00</updated><title type='text'>DELETE and TRUNCATE behavior</title><content type='html'>&lt;pre class=&quot;code&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;We will create a student table then apply Delete and Truncate within Transaction and rollback. Leave your comment about the behavior and/or output you expect.&lt;/font&gt;&lt;/span&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;--Create student table&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CREATE TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;&lt;/span&gt;ID &lt;span style=&quot;color: blue&quot;&gt;INT IDENTITY&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;br /&gt;&lt;/span&gt;NAME &lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;100&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;) NULL,&lt;br /&gt;&lt;/span&gt;AGE &lt;span style=&quot;color: blue&quot;&gt;INT &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;NULL,&lt;br /&gt;&lt;/span&gt;ACTIVE &lt;span style=&quot;color: blue&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;1&lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;))&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;--Insert some records&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;INSERT INTO &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT] &lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;VALUES&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Mark&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;32&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Elaine&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;32&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Elton&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;32&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;John&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;32&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    (&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Smith&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;32&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Y&#39;&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;color: green&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;--Delete records using DELETE &lt;br /&gt;--Rollback to bring back the records&lt;br /&gt;--You can because it write to the log and&lt;br /&gt;--can be rolled back&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;BEGIN TRANSACTION&lt;br /&gt;DELETE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;ROLLBACK &lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;--Select table&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;* &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Here is the output of the above select - &lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://lh6.ggpht.com/-4WbQwoJXQ8I/Tej9EGSx1EI/AAAAAAAABkA/hm39t8EUXM4/s1600-h/image%25255B3%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;127&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-sNZ7jY4N1BA/Tej9ElaecfI/AAAAAAAABkE/Bt2Y7eym7-Q/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;315&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;br&gt;&lt;br&gt;&lt;br /&gt;&lt;/font&gt;&lt;span style=&quot;color: green&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;--Do the same but use TRUNCATE TABLE&lt;br /&gt;--Note that it does not write to log  by definition&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;BEGIN TRANSACTION&lt;br /&gt;TRUNCATE TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;ROLLBACK &lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;--What do you expect ??&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;* &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/5322218478544223702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/delete-and-truncate-behavior.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/5322218478544223702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/5322218478544223702'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/delete-and-truncate-behavior.html' title='DELETE and TRUNCATE behavior'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-sNZ7jY4N1BA/Tej9ElaecfI/AAAAAAAABkE/Bt2Y7eym7-Q/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-7800242404575237466</id><published>2011-06-02T13:50:00.001-07:00</published><updated>2011-06-03T09:42:16.019-07:00</updated><title type='text'>Dynamic vs Static set in SSAS</title><content type='html'>&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;We deal with named set a lot when it comes to access multi dimensional data from the cube. There are two types of named set – Static and Dynamic. Till SQL Server 2005 we had only Static named set but now in SQL Server 2008 both are supported (static and dynamic named set).&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;You create named set either using CREATE SET (when defined in the cube) or WITH SET MDX (when defined in the MDX/Report) syntax. In case of static member, it get evaluated when the CREATE SET statement is executed or MDX is executed in case when it is defined in MDX using WITH SET. In case of static named set once it is executed it persists static during whole session or query or cube. In effect what will happen since named set is static and cached it will give same set of members even when you query with different condition and expect different result. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Assume a case where you need to get top 10 product by sales for whole period and then for a month. So after you run the query for whole period, you will end up getting same set of products for a month also when you execute next. So in such glitches we now have option to create dynamic set which works well.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;I will explain what exactly I mean by all this. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Create a static set in the cube as under. In my example I am retrieving top 5 products based on sale. &lt;/font&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;CREATE SET CURRENTCUBE&lt;/span&gt;.[TOP PRODUCT SALES]&lt;br /&gt; &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;&lt;span style=&quot;color: maroon&quot;&gt;TOPCOUNT&lt;/span&gt;(&lt;br /&gt;        [INVESTMENT PRODUCT].[PRODUCT NAME].[PRODUCT NAME].&lt;span style=&quot;color: blue&quot;&gt;MEMBERS&lt;/span&gt;,&lt;br /&gt;        5,&lt;br /&gt;        [MEASURES].[INV PROD SALES ACTUAL]) ;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Next, run following MDX to get top 5 product sales. Note that I am not using any time slicer here so what I am getting in here is across the time.&lt;br&gt;&lt;/font&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    [MEASURES].[INV PROD SALES ACTUAL]&lt;br /&gt;} &lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;/span&gt;,&lt;br /&gt;{&lt;br /&gt;    &lt;span style=&quot;color: maroon&quot;&gt;NONEMPTY&lt;/span&gt;([TOP PRODUCT SALES], &lt;br /&gt;    [MEASURES].[INV PROD SALES ACTUAL])&lt;br /&gt;} &lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;ON ROWS&lt;br /&gt;FROM &lt;/span&gt;[YOUR_CUBE];&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Here is output of above MDX.&lt;br&gt;&lt;a href=&quot;http://lh4.ggpht.com/-wZe6a_-NPrg/TekO3amJ-mI/AAAAAAAABkI/7EvGkrsyBT8/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;117&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-ShiC6s3W0Ig/TekO36y8SLI/AAAAAAAABkM/jDHtYqrcygk/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;314&quot; border=&quot;0&quot;&gt;&lt;/a&gt;  &lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Next let’s apply February time filter in the MDX and I expect at least 1-2 different product than one we got above. &lt;br&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    [MEASURES].[INV PROD SALES ACTUAL]&lt;br /&gt;} &lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;/span&gt;,&lt;br /&gt;{&lt;br /&gt;    &lt;span style=&quot;color: maroon&quot;&gt;NONEMPTY&lt;/span&gt;([TOP PRODUCT SALES], &lt;br /&gt;    [MEASURES].[INV PROD SALES ACTUAL])&lt;br /&gt;} &lt;span style=&quot;color: blue&quot;&gt;ON ROWS&lt;br /&gt;FROM &lt;/span&gt;[YOUR CUBE]&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;WHERE &lt;/span&gt;[TIME].[YQMD].[Month].&amp;amp;[2011-02-01T00:00:00]&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Here is the output of above MDX - &lt;br&gt;&lt;a href=&quot;http://lh5.ggpht.com/-woiGWq7MCps/TekO4S5S7yI/AAAAAAAABkQ/QOhQJHglXwY/s1600-h/image%25255B8%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;123&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-H0bcN8fXCJ0/TekO4wQ-lwI/AAAAAAAABkU/PbsjYjbphfw/image_thumb%25255B3%25255D.png?imgmax=800&quot; width=&quot;321&quot; border=&quot;0&quot;&gt;&lt;/a&gt;  &lt;br&gt;Note that though we now got different sales actual, it is the same set of products we earlier got when we ran without using any time filter. So what is happening here is when we created the set using CREATE SET statement in the cube and processed it, it evaluated the top 5 products and same set is being returned.&lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;Now let’s change the set type to dynamic and retry the MDX and this time we expect it to be dynamic. Meaning, we should get different set of products based on top 5 sales when passed different time filter.&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;CREATE DYNAMIC SET CURRENTCUBE&lt;/span&gt;.[TOP PRODUCT SALES]&lt;br /&gt; &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;&lt;span style=&quot;color: maroon&quot;&gt;TOPCOUNT&lt;/span&gt;(&lt;br /&gt;        [INVESTMENT PRODUCT].[PRODUCT NAME].[PRODUCT NAME].&lt;span style=&quot;color: blue&quot;&gt;MEMBERS&lt;/span&gt;,&lt;br /&gt;        5,&lt;br /&gt;        [MEASURES].[INV PROD SALES ACTUAL]) ; &lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;Now run above 2 MDX queries and analyze the result.They should be different now.&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    [MEASURES].[INV PROD SALES ACTUAL]&lt;br /&gt;} &lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;/span&gt;,&lt;br /&gt;{&lt;br /&gt;    &lt;span style=&quot;color: maroon&quot;&gt;NONEMPTY&lt;/span&gt;([TOP PRODUCT SALES], &lt;br /&gt;    [MEASURES].[INV PROD SALES ACTUAL])&lt;br /&gt;} &lt;span style=&quot;color: blue&quot;&gt;ON ROWS&lt;br /&gt;FROM &lt;/span&gt;[YOUR CUBE]&lt;font size=&quot;2&quot;&gt;&lt;br&gt;&lt;/pre&gt;&lt;/font&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;a href=&quot;http://lh4.ggpht.com/-wZe6a_-NPrg/TekO3amJ-mI/AAAAAAAABkI/7EvGkrsyBT8/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;117&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-ShiC6s3W0Ig/TekO36y8SLI/AAAAAAAABkM/jDHtYqrcygk/image_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;314&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;br&gt;SELECT &lt;br /&gt;&lt;/span&gt;{&lt;br /&gt;    [MEASURES].[INV PROD SALES ACTUAL]&lt;br /&gt;} &lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;/span&gt;,&lt;br /&gt;{&lt;br /&gt;    &lt;span style=&quot;color: maroon&quot;&gt;NONEMPTY&lt;/span&gt;([TOP PRODUCT SALES], &lt;br /&gt;    [MEASURES].[INV PROD SALES ACTUAL])&lt;br /&gt;} &lt;span style=&quot;color: blue&quot;&gt;ON ROWS&lt;br /&gt;FROM &lt;/span&gt;[YOUR CUBE]&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;WHERE &lt;/span&gt;[TIME].[YQMD].[Month].&amp;amp;[2011-02-01T00:00:00]&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://lh6.ggpht.com/-MYMgQEuNzjY/TekO5dLTgpI/AAAAAAAABkY/XfY60LKSbsQ/s1600-h/image%25255B12%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;125&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-YEjqh1EoCew/TekO526eXTI/AAAAAAAABkc/EpNLAoxVL4U/image_thumb%25255B5%25255D.png?imgmax=800&quot; width=&quot;327&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&amp;nbsp; &lt;br&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Now you would have noticed that we are getting different set of top 5 products and it is correct now and reflecting per sales. Please leave your feedback/comment.&lt;/font&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/7800242404575237466/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/dynamic-vs-static-set-in-ssas.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/7800242404575237466'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/7800242404575237466'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/dynamic-vs-static-set-in-ssas.html' title='Dynamic vs Static set in SSAS'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-ShiC6s3W0Ig/TekO36y8SLI/AAAAAAAABkM/jDHtYqrcygk/s72-c/image_thumb%25255B1%25255D.png?imgmax=800" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-6639531011580161860</id><published>2011-06-01T13:16:00.001-07:00</published><updated>2011-06-02T08:28:21.799-07:00</updated><title type='text'>Date dimension to support multiple fiscal year</title><content type='html'>&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;If you have requirement to present your data based on the fiscal year user is using, you can provide user with option to either select fiscal year he wants or can make it dynamic in the report such that it dynamically select the current user location and render the report.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;This is one way to model your time dimension to support multiple fiscal year. There are obviously other ways to support various fiscal year like by adding more columns to time dimensions, storing into separate fact for each single fiscal year you may need to support, building separate hierarchies for each fiscal year etc. I insist the approach because you don’t have to add columns in the database time dimension table to support and of course it is not considered good to add columns to support piece of business. We should always try and see if it can be done using same table columns. &lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;We will create 3 tables. Find script below to create these tables. We will create a calendar dimension table with all the attributes, a Date dimension table with key and date and a bridge table to connect these two dimension tables (Calendar and Date).&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Here is the script to create 3 tables - &lt;/font&gt;&lt;/p&gt; &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;518&quot; border=&quot;1&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; width=&quot;516&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;//&lt;/span&gt;Calendar dimension table&lt;br&gt;CREATE &lt;span style=&quot;color: blue&quot;&gt;TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_DIM_CALENDAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;            &lt;/span&gt;[CALENDAR_KEY] [INT] &lt;span style=&quot;color: blue&quot;&gt;IDENTITY&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;br /&gt;            &lt;/span&gt;[CALENDAR_DATE_ID] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;100&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[CALENDAR_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;50&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[CALENDAR_ORDER] [TINYINT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[ACTUAL_DATE] [DATE] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[DATE_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;50&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[YEAR] [DATE] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[YEAR_NAME] [CHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;4&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[QUARTER] [DATE] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[QUARTER_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;9&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[MONTH] [DATE] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[MONTH_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;14&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[WEEK] [DATE] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[WEEK_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;12&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[DAY_OF_YEAR] [SMALLINT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[DAY_OF_YEAR_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;7&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[DAY_OF_QUARTER] [TINYINT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[DAY_OF_QUARTER_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;6&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[DAY_OF_WEEK] [TINYINT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[DAY_OF_WEEK_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;5&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[WEEK_OF_YEAR] [TINYINT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[WEEK_OF_YEAR_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;7&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[MONTH_OF_YEAR] [TINYINT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[MONTH_OF_YEAR_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;36&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[MONTH_OF_QUARTER] [TINYINT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[MONTH_OF_QUARTER_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;8&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;            &lt;/span&gt;[QUARTER_OF_YEAR] [TINYINT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt;            &lt;/span&gt;[QUARTER_OF_YEAR_NAME] [VARCHAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;9&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;)//&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;Date &lt;/span&gt;dimension &lt;span style=&quot;color: blue&quot;&gt;table&lt;br /&gt;CREATE TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_DIM_DATE]&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;        &lt;/span&gt;[DATE_KEY] [INT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;br /&gt;        &lt;/span&gt;[ACTUAL_DATE] [DATETIME] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL,&lt;br /&gt; )//&lt;/span&gt;Bridge fact &lt;span style=&quot;color: blue&quot;&gt;table&lt;br /&gt;CREATE TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_DIM_DATE_CALENDAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;            &lt;/span&gt;[DATE_KEY] [INT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;REFERENCES &lt;br&gt;&lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_DIM_DATE]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;[DATE_KEY]&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;            &lt;/span&gt;[CALENDAR_KEY] [INT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;REFERENCES &lt;br&gt;&lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_DIM_CALENDAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;[CALENDAR_KEY]&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;GO&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Let’s setup data source view in the OLAP. Add above 3 tables in the DSV, you should get this - &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-WX0qMF9X1Vo/Tead6R2lW1I/AAAAAAAABho/Z1OmyQwEPrc/s1600-h/image7.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;484&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-vyL4SFLDLvk/Tead6-b3eOI/AAAAAAAABhs/pPrUHDd-M1g/image_thumb3.png?imgmax=800&quot; width=&quot;418&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Next populate above tables using SQL script. Make sure you have entries for each single day in this table. You need to have entries per Gregorian calendar and same number of entries for each month of a year starting February (and of course for each year) . Reason, we are not creating entries for January because if fiscal starts from January it will be same as calendar year.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Here is the sample script to populate above tables.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;543&quot; border=&quot;1&quot;&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;541&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;DECLARE &lt;/span&gt;@STARTDATE &lt;span style=&quot;color: blue&quot;&gt;DATETIME &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;2008-01-01&#39;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;DECLARE &lt;/span&gt;@ENDDATE &lt;span style=&quot;color: blue&quot;&gt;DATETIME &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;2010-12-31&#39;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;DECLARE &lt;/span&gt;@COUNTER &lt;span style=&quot;color: blue&quot;&gt;INT&lt;br /&gt;SET &lt;/span&gt;@COUNTER &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;1&lt;br /&gt;&lt;span style=&quot;color: gray&quot;&gt;;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WITH &lt;/span&gt;DATES&lt;span style=&quot;color: gray&quot;&gt;( &lt;/span&gt;D &lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(  &lt;br /&gt;     &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;@STARTDATE &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;D &lt;br /&gt;           &lt;span style=&quot;color: blue&quot;&gt;UNION &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;ALL &lt;br /&gt;     &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DAY&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;)  &lt;br /&gt;           &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;DATES  &lt;br /&gt;           &lt;span style=&quot;color: blue&quot;&gt;WHERE &lt;/span&gt;D &lt;span style=&quot;color: gray&quot;&gt;&amp;lt; &lt;/span&gt;@ENDDATE  &lt;br /&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;,&lt;/span&gt;MONTHS&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;M&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;@COUNTER &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;M&lt;br /&gt;          &lt;span style=&quot;color: blue&quot;&gt;UNION &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;ALL&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;M &lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;1&lt;br /&gt;          &lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;MONTHS&lt;br /&gt;          &lt;span style=&quot;color: blue&quot;&gt;WHERE &lt;/span&gt;M &lt;span style=&quot;color: gray&quot;&gt;&amp;lt;= &lt;/span&gt;11&lt;br /&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;INSERT INTO &lt;/span&gt;TTB_DIM_CALENDAR &lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;&lt;/span&gt;CALENDAR_DATE_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;CALENDAR_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;CALENDAR_ORDER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUAL_DATE&lt;span style=&quot;color: gray&quot;&gt;,&lt;br&gt;&lt;/span&gt;DATE_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;YEAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;YEAR_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;QUARTER&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;QUARTER_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;br /&gt;&lt;/span&gt;MONTH_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WEEK&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;WEEK_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;DAY_OF_YEAR&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;DAY_OF_YEAR_NAME&lt;span style=&quot;color: gray&quot;&gt;,&lt;br&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt; &lt;/span&gt;DAY_OF_QUARTER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;DAY_OF_QUARTER_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;DAY_OF_WEEK&lt;span style=&quot;color: gray&quot;&gt;, &lt;br /&gt;&lt;/span&gt;DAY_OF_WEEK_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;WEEK_OF_YEAR&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;WEEK_OF_YEAR_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;MONTH_OF_YEAR&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;&lt;/span&gt;MONTH_OF_YEAR_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;br /&gt;&lt;/span&gt;MONTH_OF_QUARTER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;MONTH_OF_QUARTER_NAME&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;QUARTER_OF_YEAR&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;&lt;/span&gt;QUARTER_OF_YEAR_NAME&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT&lt;br /&gt;     CASE WHEN &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;LEN&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;FISCALSTARTMONTH&lt;span style=&quot;color: gray&quot;&gt;) = &lt;/span&gt;1 &lt;span style=&quot;color: blue&quot;&gt;THEN &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;0&#39; &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;ELSE &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;&#39; &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;END &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;&lt;br&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;8&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;FISCALSTARTMONTH&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;_&#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;CALENDARKEY &lt;span style=&quot;color: blue&quot;&gt;AS &lt;br&gt;&lt;/span&gt;CALENDARDATEID&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;CALENDARNAME&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;FISCALSTARTMONTH&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;ACTUALDATE&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;[DATENAME]&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;[YEAR]&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;4&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;YYYY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;YEARNAME&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;Q&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CEILING&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;br&gt;&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)/&lt;/span&gt;3.0&lt;span style=&quot;color: gray&quot;&gt;) - &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;[QUARTER]&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;4&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;YYYY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;)) + &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39; Q&#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;br&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CEILING&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)/&lt;/span&gt;3.0&lt;span style=&quot;color: gray&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;br&gt;AS &lt;/span&gt;QUARTERNAME&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;[MONTH]&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATENAME&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;)) + &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39; &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;br&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;4&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;YYYY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;[MONTHNAME]&lt;br /&gt;    &lt;span style=&quot;color: green&quot;&gt;--,(DATEDIFF(MM, [YEAR], ACTUALDATE) + 1) AS [MONTHNUMBER]&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;WK&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;WK&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;[WEEK]&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;WEEK &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;,(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;WK&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;br&gt;&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)) + &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39; &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;4&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;YYYY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;[WEEKNAME]&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;DY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1 &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;[DAYOFYEAR]&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;DAY &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;DY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;br&gt;&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;DAYOFYEARNAME&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;DY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;Q&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CEILING&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;&lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)/&lt;/span&gt;3.0&lt;span style=&quot;color: gray&quot;&gt;) - &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1 &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;DAYOFQUARTER&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;DAY &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;DY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;Q&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CEILING&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;br&gt;((&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)/&lt;/span&gt;3.0&lt;span style=&quot;color: gray&quot;&gt;) - &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;), &lt;br&gt;&lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;DAYOFQUARTERNAME&lt;br&gt;&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;DW&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;[DAYOFWEEK]&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;DAY &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;DW&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;br&gt;&lt;/span&gt;DAYOFWEEKNAME&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;WK&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1 &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;WEEKOFYEAR&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;WEEK &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;WK&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;br&gt;&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;WEEKOFYEARNAME&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1 &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;MONTHOFYEAR&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;MONTH &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) &lt;br&gt;+ &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;MONTHOFYEARNAME&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;Q&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CEILING&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;&lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)/&lt;/span&gt;3.0&lt;span style=&quot;color: gray&quot;&gt;) - &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;&lt;br&gt;&lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;)) + &lt;/span&gt;1 &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;MONTHOFQUARTER&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;MONTH &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;Q&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CEILING&lt;br&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)/&lt;/span&gt;3.0&lt;span style=&quot;color: gray&quot;&gt;) - &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;&lt;br&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;)) + &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;br&gt;&lt;/span&gt;MONTHOFQUARTERNAME&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CEILING&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)/&lt;/span&gt;3.0&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;br&gt;&lt;/span&gt;QUARTEROFYEAR&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;QUARTER &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CEILING&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;((&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;&lt;/span&gt;[YEAR]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUALDATE&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)/&lt;/span&gt;3.0&lt;span style=&quot;color: gray&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;QUARTEROFYEARNAME&lt;br&gt;&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT&lt;br /&gt;           &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;8&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;112&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;CALENDARKEY&lt;br /&gt;          &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;M &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;FISCALSTARTMONTH&lt;br /&gt;          &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CASE&lt;br /&gt;                WHEN &lt;/span&gt;M &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;1 &lt;span style=&quot;color: blue&quot;&gt;THEN &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;GREGORIAN&#39;&lt;br /&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;ELSE &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATENAME&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;br&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, (&lt;/span&gt;M&lt;span style=&quot;color: gray&quot;&gt;-&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;))) &lt;br&gt;+ &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39; BASED FISCAL&#39;&lt;br /&gt;           &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;END AS &lt;/span&gt;CALENDARNAME&lt;br /&gt;          &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;D &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;ACTUALDATE&lt;br /&gt;          &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATENAME&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;DW&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;)+ &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;, &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATENAME&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39; &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ RIGHT&lt;br&gt;(&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;00&#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;2&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;)), &lt;/span&gt;2&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39; &#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;br&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;4&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;YYYY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;[DATENAME]&lt;br /&gt;          &lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CASE&lt;br /&gt;                WHEN &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;) &amp;gt;= &lt;/span&gt;M &lt;span style=&quot;color: blue&quot;&gt;THEN &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;(&lt;/span&gt;M&lt;span style=&quot;color: gray&quot;&gt;-&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;YEAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;YEAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;))&lt;br /&gt;                &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WHEN &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEPART&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;) &amp;lt; &lt;/span&gt;M &lt;span style=&quot;color: blue&quot;&gt;THEN &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;MONTH&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, (&lt;/span&gt;M&lt;span style=&quot;color: gray&quot;&gt;-&lt;br&gt;&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;)-&lt;/span&gt;12&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;YEAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEDIFF&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;YEAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;0&lt;span style=&quot;color: gray&quot;&gt;))&lt;br&gt;&lt;br /&gt;           &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;END AS &lt;/span&gt;[YEAR]&lt;br /&gt;    &lt;span style=&quot;color: blue&quot;&gt;FROM&lt;br /&gt;          &lt;/span&gt;DATES&lt;br /&gt;          &lt;span style=&quot;color: gray&quot;&gt;CROSS JOIN &lt;br /&gt;                &lt;/span&gt;MONTHS&lt;br /&gt;&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;DATES&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;OPTION &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MAXRECURSION 10000&lt;span style=&quot;color: gray&quot;&gt;) &lt;br /&gt;&lt;br /&gt;;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WITH &lt;/span&gt;DATES&lt;span style=&quot;color: gray&quot;&gt;( &lt;/span&gt;D &lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(  &lt;br /&gt;     &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;@STARTDATE &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;D &lt;br /&gt;           &lt;span style=&quot;color: blue&quot;&gt;UNION &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;ALL &lt;br /&gt;     &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DATEADD&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;DAY&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;)  &lt;br /&gt;           &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;DATES  &lt;br /&gt;           &lt;span style=&quot;color: blue&quot;&gt;WHERE &lt;/span&gt;D &lt;span style=&quot;color: gray&quot;&gt;&amp;lt; &lt;/span&gt;@ENDDATE  &lt;br /&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;INSERT INTO &lt;/span&gt;TTB_DIM_DATE &lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;DATE_KEY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;ACTUAL_DATE&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;8&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;112&lt;span style=&quot;color: gray&quot;&gt;)) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;DATEKEY&lt;span style=&quot;color: gray&quot;&gt;,&lt;br /&gt;    &lt;/span&gt;D &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;ACTUALDATE&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM&lt;br /&gt;    &lt;/span&gt;DATES&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;OPTION &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;MAXRECURSION 10000&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;INSERT INTO &lt;/span&gt;[TTB_DIM_DATE_CALENDAR] &lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;DATE_KEY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;CALENDAR_KEY&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT&lt;br /&gt;    &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;DATE_KEY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;C&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;CALENDAR_KEY&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM&lt;br /&gt;    &lt;/span&gt;TTB_DIM_DATE D&lt;br /&gt;    &lt;span style=&quot;color: gray&quot;&gt;INNER JOIN &lt;/span&gt;TTB_DIM_CALENDAR C &lt;span style=&quot;color: blue&quot;&gt;ON&lt;br /&gt;          &lt;/span&gt;D&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;DATE_KEY &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;INT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, RIGHT(&lt;/span&gt;C&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;CALENDAR_DATE_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;8&lt;span style=&quot;color: gray&quot;&gt;))&lt;/span&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;/font&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;At this point if I assume you have just populated one year entries into the calendar dimension this is how number of entries should be in the calendar dimension table -&lt;br&gt;&lt;a href=&quot;http://lh4.ggpht.com/-E19W3Jm3E80/TeehMCsQ09I/AAAAAAAABjY/Erl0gjNtEiU/s1600-h/image%25255B12%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;135&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-Spkk0sii3mg/TeehNPgJw4I/AAAAAAAABjc/FT0nYjSR3lc/image_thumb%25255B7%25255D.png?imgmax=800&quot; width=&quot;409&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Add calendar and set dimension properties as under - &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-6nnGhDOoEjc/Tead7OQCewI/AAAAAAAABhw/vrzqIY6dwJk/s1600-h/image12.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;244&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-dSzyAzrmkqo/Tead7TeOsGI/AAAAAAAABh0/sRqhxGkFmlo/image_thumb6.png?imgmax=800&quot; width=&quot;224&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Set additional calendar attribute properties as under - &lt;br&gt;&lt;a href=&quot;http://lh5.ggpht.com/-hD2Ru8uMMjk/TeehORmY9lI/AAAAAAAABjg/7MqaTh92Ems/s1600-h/image%25255B21%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;326&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-OHSJfemTCWw/TeehOkbKUXI/AAAAAAAABjk/2zeSzAwVFeI/image_thumb%25255B14%25255D.png?imgmax=800&quot; width=&quot;613&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Next build hierarchy and set attribute relationship as under - &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-HAMv9J-ndjM/Tead7lPZRWI/AAAAAAAABh4/klekTlYV9qY/s1600-h/image16.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;39&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-0W9HDURh5DE/Tead8A3DVZI/AAAAAAAABh8/Bf_JWUhVf00/image_thumb8.png?imgmax=800&quot; width=&quot;644&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-7SvW0V46itA/Tead8uJWavI/AAAAAAAABiA/V8ITA09jB20/s1600-h/image20.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;280&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-N06RmS41W58/Tead8wai1QI/AAAAAAAABiE/PJzTFlngdT4/image_thumb10.png?imgmax=800&quot; width=&quot;644&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Add Date dimension and leave everything to default value. I however changed the key column to Date from Date_Key. Here is the snap of the Date dimension - &lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-NfTTa183Xlc/Tead9aIKFaI/AAAAAAAABiI/nq3mmTzZ9NM/s1600-h/image%25255B5%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;200&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-fM0D-CUJMkE/Tead-KxF-vI/AAAAAAAABiM/iFM_0DruFe8/image_thumb%25255B3%25255D.png?imgmax=800&quot; width=&quot;361&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Now we will add a fact table (actual fact) for sales. Fact table will be linked to calendar and date dimensions.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;509&quot; border=&quot;1&quot;&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;507&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;CREATE TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_FACT_SALES]&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;    &lt;/span&gt;[DATE_KEY] [INT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;REFERENCES &lt;br&gt;&lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_DIM_DATE]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;[DATE_KEY]&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    &lt;/span&gt;[CALENDAR_KEY] [INT] &lt;span style=&quot;color: gray&quot;&gt;NOT NULL &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;REFERENCES &lt;br&gt;&lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_DIM_CALENDAR]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;[CALENDAR_KEY]&lt;span style=&quot;color: gray&quot;&gt;),&lt;br /&gt;    &lt;/span&gt;[SALES_AMOUNT] &lt;span style=&quot;color: blue&quot;&gt;DECIMAL&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;10&lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;2&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;)&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Add above fact table to data source view and it should look like this at this point - &lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-hUsJzkgc5Z4/Tead-f1r3FI/AAAAAAAABiQ/9co2UGvrgeo/s1600-h/image%25255B9%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;405&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-kobnq-A7Ork/Tead_JUJnUI/AAAAAAAABiU/fraRldQSZwo/image_thumb%25255B5%25255D.png?imgmax=800&quot; width=&quot;402&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Create a measure from the bridge table. This will act as intermediate fact table when we join with sales fact through calendar dimension (using many to many relationship and will be discussed later). It is nothing but the fact less fact table and we will not be using this for anything. Let’s add count measure on Date_key column. Here is what I mean -&lt;/font&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-9B8anhaeYms/TeaeAKktoQI/AAAAAAAABiY/sJfJKPJ__v8/s1600-h/image%25255B37%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;63&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-FSK3lHxbNZ0/TeaeBDNiimI/AAAAAAAABic/Br06scJ3B1o/image_thumb%25255B21%25255D.png?imgmax=800&quot; width=&quot;193&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-SDdvt4s5uF8/TeaeBc3UDcI/AAAAAAAABig/AGGFbQHDPcI/s1600-h/image%25255B17%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;233&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-wrnxkMNl_5o/TeaeBjPEk7I/AAAAAAAABik/0xuEWeE60us/image_thumb%25255B9%25255D.png?imgmax=800&quot; width=&quot;319&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Populate sales fact table as under. I just created for all the possible date and calendar key combination for us to be able to test with some data.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; width=&quot;553&quot; border=&quot;1&quot;&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td valign=&quot;top&quot; width=&quot;551&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;INSERT INTO &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_FACT_SALES]&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;[DATE_KEY]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[CALENDAR_KEY]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[SALES_AMOUNT]&lt;span style=&quot;color: gray&quot;&gt;) &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;DATE_KEY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;CALENDAR_KEY&lt;span style=&quot;color: gray&quot;&gt;, RIGHT(&lt;/span&gt;DATE_KEY&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;2&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_DIM_DATE_CALENDAR]&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Next add sales measure to the cube and leave everything else to default. This is how cube structure should look like.&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-L2y8IvF09Tg/TeaeB4J2ZkI/AAAAAAAABio/-khsp66d3Cg/s1600-h/image%25255B22%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;359&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-lRnyuffkCB8/TeaeCaE-ZKI/AAAAAAAABis/L-mJjDbyE4E/image_thumb%25255B12%25255D.png?imgmax=800&quot; width=&quot;572&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Set the dimension usage tab as under. Link &lt;strong&gt;DATE CALENDAR&lt;/strong&gt; measure group with Calendar and Date dimension using Regular relationship type. This measure group we will be using when linking with actual fact which is sales in this case.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Link sales fact with Date dimension using Regular relationship type and with calendar dimension using many to many relationship type through bridge table measure group (above one). Find below dimension usage tab and many to many relationship snap for your to connect well.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/-NV3HaoN9zfo/TeaeCyApxyI/AAAAAAAABiw/KyF9PfFGZ7U/s1600-h/image%25255B26%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;158&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-eUYJUWVlDBI/TeaeDW8XFKI/AAAAAAAABi0/qrPEdoIrL9s/image_thumb%25255B14%25255D.png?imgmax=800&quot; width=&quot;384&quot; border=&quot;0&quot;&gt;&lt;/a&gt;&amp;nbsp; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-4qydmO4JvQw/TeaeDyX2vhI/AAAAAAAABi4/nT14JGLv41k/s1600-h/image%25255B31%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;307&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-2qGHIed9NS4/TeaeEEzqqmI/AAAAAAAABi8/3HAPorWZCYI/image_thumb%25255B17%25255D.png?imgmax=800&quot; width=&quot;440&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Process the cube and analyze what we got in here. Drag sales in the measure area and calendar hierarchy. This is what we get, all the values are same for the Calendar name because we had set IsAggregatable = False.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-EQKhzJ6N-wI/TeaeEUYmspI/AAAAAAAABjA/64fWVTwHl5I/s1600-h/image%25255B35%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;211&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-jTvGvmHyz2A/TeaeINJ7wyI/AAAAAAAABjE/r6ck98qmDBE/image_thumb%25255B19%25255D.png?imgmax=800&quot; width=&quot;432&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;What we gonna see next is interesting. In Gregorian calendar March falls in Q1 and in March based fiscal again it will fall in Q1 but in April based fiscal April will fall in Q1. Similarly in Gregorian calendar May falls in Q2 but in April based fiscal it will fall in Q1 etc. So what I am driving here is, sales value will be accrued to different quarter in a year based on what is the starting month of a fiscal.&lt;/font&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-LOTyeYhSC08/TeaeIQTq7AI/AAAAAAAABjI/c4-38Yn4mZQ/s1600-h/image%25255B41%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;314&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-cA9cFHAtOpI/TeaeI9L7WuI/AAAAAAAABjM/vwH7nNL9W2M/image_thumb%25255B23%25255D.png?imgmax=800&quot; width=&quot;394&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh5.ggpht.com/-I03Uw28FKys/TeaeJN6ij8I/AAAAAAAABjQ/EHfsfVVWak0/s1600-h/image%25255B48%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;392&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-jUorgHCYq_s/TeaeJzjkgeI/AAAAAAAABjU/OPiiNLdaprw/image_thumb%25255B28%25255D.png?imgmax=800&quot; width=&quot;411&quot; border=&quot;0&quot;&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Rest you browse the cube and check the sales value distribution. Hope this will help you design time dimension when you have to support different calendar, fiscal etc. Thank you and bye for now!&lt;/font&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/6639531011580161860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/date-dimension-to-handle-multiple.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6639531011580161860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6639531011580161860'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/06/date-dimension-to-handle-multiple.html' title='Date dimension to support multiple fiscal year'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-vyL4SFLDLvk/Tead6-b3eOI/AAAAAAAABhs/pPrUHDd-M1g/s72-c/image_thumb3.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-635713054567520024</id><published>2011-05-27T10:48:00.001-07:00</published><updated>2011-06-03T07:06:09.101-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SSIS"/><title type='text'>SSIS Lookup and Conditional Split tasks to load data incrementally</title><content type='html'>&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Microsoft integration service slowly changing dimensions out of box task can be used to implement SCD Type 1 and SCD Type 2. The main challenge ETL developer faces is around selecting right approach in loading data incrementally. We have to consider the aspects like – amount of data, whether to implement Type – 1 or Type – 2 of SCD. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;There are lot of ways to load data incrementally like - &lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span&gt;SSIS Component (Lookup, conditional split etc)&lt;/span&gt; &lt;/font&gt;&lt;/font&gt; &lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span&gt;Third party components&lt;/span&gt; &lt;/font&gt;&lt;/font&gt; &lt;li&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Using SQL MERGE statement&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;I have plan to cover above three implementation approach in my coming blogs..today will talk about SCD using Lookup, Conditional Split tasks. We will create a SSIS package using these tasks to - &lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span&gt;Figure out whether incoming value in the pipe already exists in database.&lt;/span&gt; &lt;/font&gt;&lt;/font&gt; &lt;li&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Lookup column data has been changed or same as one in the database.&lt;/font&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;First Create a table and populate some records. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;CREATE TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br&gt;   &lt;/span&gt;ID      &lt;span style=&quot;color: blue&quot;&gt;INT &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;NOT NULL &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;IDENTITY &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;1&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;PRIMARY KEY&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;br&gt;   &lt;/span&gt;NAME    &lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;100&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;) NULL,&lt;br&gt;   &lt;/span&gt;AGE     &lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;INT&lt;br&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;)&lt;br&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;GO&lt;br&gt;INSERT INTO &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT] &lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;VALUES&lt;br&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Elaine&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;30&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br&gt;(&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Kevin&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;42&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br&gt;(&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Robin&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;22&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;),&lt;br&gt;(&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;Alice&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;15&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;GO&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Select above table and see the result - &lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;* &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;a href=&quot;http://lh3.ggpht.com/-eDVMFBHy1mw/Td_lkj01RtI/AAAAAAAABhY/t1U6hqako60/s1600-h/image%25255B29%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;101&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-wcqo2_7qnW8/Td_llE3f-1I/AAAAAAAABhc/CP_Br5sbeIs/image_thumb%25255B15%25255D.png?imgmax=800&quot; width=&quot;250&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Find below the package and the tasks we used. &lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;a href=&quot;http://lh3.ggpht.com/-8mOFPV_ld7k/Td_jwcm2jWI/AAAAAAAABgQ/uY82m16H07M/s1600-h/image%25255B10%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;474&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-5y4izmoHwBM/Td_jw7qwn0I/AAAAAAAABgU/w2TTZuUryfk/image_thumb%25255B6%25255D.png?imgmax=800&quot; width=&quot;515&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;We are using script component task as &lt;strong&gt;Source&lt;/strong&gt; (you will be prompted with options like source, target etc when you drag a script component tasks on package designer) to create source for the downstream transformation tasks. Set the output name as &lt;strong&gt;MyOutput &lt;/strong&gt;and add 2 columns as under. &lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;a href=&quot;http://lh6.ggpht.com/-OvSPYoraNaY/Td_jxZwNS9I/AAAAAAAABgY/PFK0WoSvdBc/s1600-h/image33.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;480&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-OiioPFbCt8A/Td_jxohRYQI/AAAAAAAABgc/HsxfJqqiTZM/image_thumb29.png?imgmax=800&quot; width=&quot;488&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/pre&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Go back to Script tab and click on &lt;strong&gt;Edit Script…&lt;/strong&gt; button and place following code snippet. We are adding some student rows to test all 3 scenarios.&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;/font&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;public override void&lt;/span&gt;CreateNewOutputRows()&lt;br&gt;{&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;/*&lt;br&gt;Lets add some student rows such that we cover&lt;br&gt;New student, Student with same age and student with&lt;br&gt;different age.&lt;br&gt;*/&lt;br&gt;&lt;br&gt;//Existing student with different age&lt;br&gt;&lt;/span&gt;MyOutputBuffer.AddRow();&lt;br&gt;MyOutputBuffer.StudentName = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Elaine&quot;&lt;/span&gt;;&lt;br&gt;MyOutputBuffer.Age = 33;&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;//Existing student with same age&lt;br&gt;&lt;/span&gt;MyOutputBuffer.AddRow();&lt;br&gt;MyOutputBuffer.StudentName = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Kevin&quot;&lt;/span&gt;;&lt;br&gt;MyOutputBuffer.Age = 42;&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;//New student&lt;br&gt;&lt;/span&gt;MyOutputBuffer.AddRow();&lt;br&gt;MyOutputBuffer.StudentName = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;Cameron&quot;&lt;/span&gt;;&lt;br&gt;MyOutputBuffer.Age = 55;&lt;br&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;I will just run the package at this point by adding data viewer for you to check dataset that we have built to be used as source for lookup task (note that you have to connect script component output to a task before you run the package).&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-hsCXPlTV_fg/Td_jyIlMjUI/AAAAAAAABgg/c8XeoNS32_c/s1600-h/image%25255B4%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;209&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-tqIQJ7SWlw4/Td_jyQhg0_I/AAAAAAAABgk/fuUhN2tcrt4/image_thumb%25255B2%25255D.png?imgmax=800&quot; width=&quot;453&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Drag a lookup tasks on the designer and set editor properties as under. Make sure you set error output for lookup match output to redirect row. I am placing the screen shot for you to be able to connect well.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Set the link between available input and lookup column as under. Here we are using student name for the equijoin and lookup column is Age.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-TNE-Vd0yxl4/Td_jy_FBKHI/AAAAAAAABgo/YcF3_O8l9Qw/s1600-h/image48.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;484&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-cywiF28QUL4/Td_jzQJufWI/AAAAAAAABgs/-qILe71rLKM/image_thumb40.png?imgmax=800&quot; width=&quot;495&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;This is how the error output should be set so that row is redirected and it can be used in the downstream transformation.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-7bWSyXwWKoM/Td_jz_f9vtI/AAAAAAAABgw/FpejG4kpYc4/s1600-h/image52.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;484&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-BiHutflohVg/Td_j0BDZuZI/AAAAAAAABg0/FqP5XVA57cY/image_thumb42.png?imgmax=800&quot; width=&quot;495&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;From lookup task we will have two outputs. First output will be for newly added students (from the source) and second output will be for existing students. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Newly added students flow we can simply connect to underline database table. Note that I have used row count tasks and store in a variable which can be used for any auditing or emailing purposes. However this is totally depends on your requirement and shall be altered per that.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Second flow (existing student with same and different age), we will connect to conditional split task for us to be able to split 2 outputs - 1. Student with same age 2. Student with different age. Note that student with same age, we don’t need to take any action. Student with different age we will connect to &lt;strong&gt;OLE DB Command&lt;/strong&gt; SSIS task through &lt;strong&gt;UNION ALL &lt;/strong&gt;task. This is how your conditional split task should be setup - &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh4.ggpht.com/-GJiMjGSXSlI/Td_j0iQiLhI/AAAAAAAABg4/9Rh9eBR99uE/s1600-h/image%25255B14%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;484&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-dloSDHWCaBY/Td_j1TgVUPI/AAAAAAAABg8/JeV04MnwduQ/image_thumb%25255B8%25255D.png?imgmax=800&quot; width=&quot;440&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;This is how your OLE DB Command task should be setup. In the &lt;strong&gt;Connection Manager &lt;/strong&gt;tab set the connection you used to connect to your relational database. In the &lt;strong&gt;Component Properties &lt;/strong&gt;tab set &lt;strong&gt;SqlCommand &lt;/strong&gt;properties with the SQL Update statement (Shown in the dialog). Note that In the &lt;strong&gt;Column Mapping &lt;/strong&gt;tab you have to specify parameters we have used in the update.&lt;br&gt;&lt;br&gt;&lt;span&gt;Component Properties tab - &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;a href=&quot;http://lh6.ggpht.com/-DcSlt996Cdk/Td_j14SnhsI/AAAAAAAABhA/vbBpLaf2IhM/s1600-h/image%25255B18%25255D.png&quot;&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;484&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/-tWtOjEryo9g/Td_j2QbHYvI/AAAAAAAABhE/5ER4Ko3gSXk/image_thumb%25255B10%25255D.png?imgmax=800&quot; width=&quot;454&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;br&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Column Mappings tab - &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;a href=&quot;http://lh6.ggpht.com/-0DBRY2Yh4oA/Td_j27vzzFI/AAAAAAAABhI/eDks8lcAVQo/s1600-h/image%25255B22%25255D.png&quot;&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;484&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-qHSY3QIVXCM/Td_j3L1qFCI/AAAAAAAABhM/Da5XKJbXr_o/image_thumb%25255B12%25255D.png?imgmax=800&quot; width=&quot;454&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;br&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Finally run the package and observe the data viewers for the 3 outputs. Remember we are not taking any action if it is existing student with same age as in database table. - &lt;/font&gt;&lt;/span&gt;&lt;a href=&quot;http://lh4.ggpht.com/-RDkE4lL7LBw/Td_j3lQyB5I/AAAAAAAABhQ/2cTwjHkUXEk/s1600-h/image%25255B26%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;357&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-EMZdy3YPvsw/Td_j4F_isfI/AAAAAAAABhU/yHzodG5_QM8/image_thumb%25255B14%25255D.png?imgmax=800&quot; width=&quot;644&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;As you could make out by looking the ETL flow, &lt;strong&gt;Elaine&lt;/strong&gt; went to OLE DB update, &lt;strong&gt;Kevin&lt;/strong&gt; went to Age is same flow (no change in age) and &lt;strong&gt;Cameron&lt;/strong&gt; went to OLE DB Insert. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Let’s select from the table again -&lt;br&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;* &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_STUDENT]&lt;br&gt;&lt;/font&gt;&lt;a href=&quot;http://lh3.ggpht.com/-deE09UVe4i4/Td_llZwKxiI/AAAAAAAABhg/sAGu6lI_4vM/s1600-h/image%25255B33%25255D.png&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;101&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-Azei7802QuU/Td_llsLdtII/AAAAAAAABhk/EjV175slsYo/image_thumb%25255B17%25255D.png?imgmax=800&quot; width=&quot;244&quot; border=&quot;0&quot;&gt;&lt;/font&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;span&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;You can do the same using out of box SCD tasks however it comes with some drawbacks and this is one of the best alternative approach. Hope the article will be helpful for you to understand and compare with other available solutions to load data incrementally. Request you to leave any feedback or comments you guys have.&lt;/font&gt; &lt;/span&gt;&lt;/p&gt;&lt;br&gt;&lt;br /&gt;&lt;p&gt;&lt;span&gt;&lt;em&gt;Bye for now, will be back with more. Enjoy long weekend!&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/635713054567520024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/ssis-lookup-and-conditional-split-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/635713054567520024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/635713054567520024'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/ssis-lookup-and-conditional-split-to.html' title='SSIS Lookup and Conditional Split tasks to load data incrementally'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-wcqo2_7qnW8/Td_llE3f-1I/AAAAAAAABhc/CP_Br5sbeIs/s72-c/image_thumb%25255B15%25255D.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-7420121652955086007</id><published>2011-05-25T11:57:00.001-07:00</published><updated>2011-06-01T11:06:55.579-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SSIS"/><title type='text'>Unpivot data transformation in SSIS</title><content type='html'>&lt;p&gt;&lt;span&gt;&lt;span  &gt;I get sales product data in an excel spreadsheet. This file holds yearly sales data of all the products. Following is the excel template business users are using to capture sales data month to month. The requirement is to unpivot the sales data and store in a table with appropriate snapshot. Find below file template with sample data - &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;http://lh3.ggpht.com/_XGHY31rLQMs/Td1RGf_UgvI/AAAAAAAABfI/-lLakhK-_fQ/s1600-h/image%5B7%5D.png&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;http://lh4.ggpht.com/-Bz0pcSlFxnQ/Td-9PTFXKbI/AAAAAAAABgA/xnGYaOAHD5U/s1600-h/image4%25255B3%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;193&quot; alt=&quot;image&quot; src=&quot;http://lh3.ggpht.com/-1a6li249IPA/Td1RGgRzDNI/AAAAAAAABgE/4kjUcoooNJ4/image4_thumb%25255B2%25255D.png?imgmax=800&quot; width=&quot;580&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;span&gt;&lt;span  &gt;Find below table structure where above file has to be imported using package.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span &gt;&lt;span &gt;&lt;span style=&quot;color: blue&quot;&gt;CREATE TABLE &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_PRODUCT_SALES]&lt;/span&gt;&lt;/span&gt;&lt;span &gt;&lt;span &gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;  &lt;/span&gt;[PRODUCT_NAME]    &lt;span style=&quot;color: blue&quot;&gt;NVARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;100&lt;/span&gt;&lt;/span&gt;&lt;span &gt;&lt;span &gt;&lt;span style=&quot;color: gray&quot;&gt;) NOT NULL,&lt;br /&gt;  &lt;/span&gt;[SALES_AMT] &lt;span style=&quot;color: blue&quot;&gt;DECIMAL&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;15&lt;span style=&quot;color: gray&quot;&gt;,&lt;/span&gt;4&lt;/span&gt;&lt;/span&gt;&lt;span &gt;&lt;span &gt;&lt;span style=&quot;color: gray&quot;&gt;) NULL,&lt;br /&gt;  &lt;/span&gt;[SNAPSHOT_DATE] &lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;50&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;span  &gt;) NULL&lt;br /&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;span  &gt;Next step would be to create a SSIS package to import data from excel file into the database table recursively such that all these months are loaded. Note that we can do this using unpivot transformation task.&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;span  &gt;Steps to create package - &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;span  &gt;Go to your integration service project in your solution and add new SSIS package.&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span  &gt;Add a data flow task under &lt;strong&gt;Control Flow&lt;/strong&gt; tab as under -&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://lh6.ggpht.com/-C2OQBTr5uf0/Td15QxxxTyI/AAAAAAAABfQ/Th15KTrxx10/s1600-h/image%25255B19%25255D.png&quot;&gt;&lt;span  &gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;68&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-07emRiyfE2s/Td15RC__E-I/AAAAAAAABfU/KsghlO8yXVE/image_thumb%25255B9%25255D.png?imgmax=800&quot; width=&quot;244&quot; border=&quot;0&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;span  &gt;Double click on the above task to go to the data flow tab. Next, right click on &lt;strong&gt;Connection Managers&lt;/strong&gt; tab and select &lt;strong&gt;Excel&lt;/strong&gt; from the connection manager list, click on &lt;strong&gt;Add…&lt;/strong&gt; button and select sales excel as your source. Make sure you checked &lt;strong&gt;First row has column names &lt;/strong&gt;in the &lt;strong&gt;Excel Connection Manager&lt;/strong&gt;.&lt;br /&gt;&lt;/span&gt;&lt;a href=&quot;http://lh3.ggpht.com/-PsgzZnZpgFs/Td15RSHYkmI/AAAAAAAABfY/sahdn7tg1BE/s1600-h/image%25255B26%25255D.png&quot;&gt;&lt;span  &gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;147&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-IlVBgFtV2ec/Td15RtFKLMI/AAAAAAAABfc/zeUBNx16J7Q/image_thumb%25255B12%25255D.png?imgmax=800&quot; width=&quot;304&quot; border=&quot;0&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span  &gt;You can add data viewer and run the package to view current state of dataset. It will be like this  -&lt;br /&gt;&lt;/span&gt;&lt;a href=&quot;http://lh3.ggpht.com/-d1pFFffAw4s/Td15R9AGKPI/AAAAAAAABfg/AyoQBcZwOS8/s1600-h/image%25255B36%25255D.png&quot;&gt;&lt;span  &gt;&lt;/span&gt;&lt;/a&gt;&lt;span  &gt;&lt;a href=&quot;http://lh3.ggpht.com/-d1pFFffAw4s/Td15R9AGKPI/AAAAAAAABgI/hUpNjowGLy0/s1600-h/image32%25255B2%25255D.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px&quot; height=&quot;277&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-XCo3Tztppys/Td15SHCskRI/AAAAAAAABgM/60Jkj30o1NI/image32_thumb%25255B1%25255D.png?imgmax=800&quot; width=&quot;644&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;span  &gt;Add Unpivot transformation tasks to unpivot sales columns into rows. Double click on Unpivot transformation task and editor as under -&lt;br /&gt;&lt;/span&gt;&lt;a href=&quot;http://lh6.ggpht.com/-0zH0YKdwmug/Td15SebHgHI/AAAAAAAABfo/ZEQf_YFhplw/s1600-h/image%25255B48%25255D.png&quot;&gt;&lt;span  &gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;448&quot; alt=&quot;image&quot; src=&quot;http://lh6.ggpht.com/-V2PT1K76FfA/Td15Sv_iujI/AAAAAAAABfs/JVc-Hg654Wg/image_thumb%25255B24%25255D.png?imgmax=800&quot; width=&quot;411&quot; border=&quot;0&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;span  &gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;&lt;span  &gt;As you see we have to pass through Product as we want to keep product and transform other columns (months like Jan, Feb etc) into rows.  Meaning, month columns will be converted into rows for each product. Set &lt;strong&gt;Destination Column&lt;/strong&gt; to &lt;strong&gt;SALES_AMT &lt;/strong&gt;to store unpivoted value in the database table. Set &lt;strong&gt;Pivot key value column name &lt;/strong&gt;to “PKeyMonth”. This variable will hold value of the pivot key value. In our example we have put month name as key (Jan, Feb etc). Add a data viewer to check incoming rows and variable value -&lt;br /&gt;&lt;/span&gt;&lt;a href=&quot;http://lh3.ggpht.com/-PjvOJAjwQEc/Td15S7ZCpfI/AAAAAAAABfw/r_F0Tb_1oqQ/s1600-h/image%25255B58%25255D.png&quot;&gt;&lt;span  &gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;450&quot; alt=&quot;image&quot; src=&quot;http://lh5.ggpht.com/-NOBsRm0YENM/Td15TFCjahI/AAAAAAAABf0/NuYc91YMaw4/image_thumb%25255B30%25255D.png?imgmax=800&quot; width=&quot;423&quot; border=&quot;0&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;span  &gt;Let’s add a script component task to read “PkeyValue” value and convert it into snapshot date. Select &lt;strong&gt;Transform&lt;/strong&gt; in the &lt;strong&gt;Select Script Component Type &lt;/strong&gt;dialog. In the &lt;strong&gt;Script Transformation Editor&lt;/strong&gt; go to &lt;strong&gt;Inputs and Outputs &lt;/strong&gt;tab and add a output column name &lt;strong&gt;SnapshotDate&lt;/strong&gt;. Next switch to &lt;strong&gt;Script &lt;/strong&gt;tab and place following script to assign snapshot date value to newly added variable. We will use this variable to set snapshot in the database table.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;br /&gt;&lt;span&gt;&lt;span  &gt;public override void &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span  &gt;Input0_ProcessInputRow(&lt;span style=&quot;color: #2b91af&quot;&gt;Input0Buffer &lt;/span&gt;Row)&lt;br /&gt;  {&lt;br /&gt;&lt;span style=&quot;color: green&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;string &lt;/span&gt;varSnapShotDate = &lt;span style=&quot;color: blue&quot;&gt;string&lt;/span&gt;.Empty;&lt;br /&gt;      &lt;span style=&quot;color: blue&quot;&gt;switch &lt;/span&gt;(Row.PKeyMonth)&lt;br /&gt;      {&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Jan&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-01-31&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Feb&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-02-28&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Mar&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-03-31&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Apr&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-04-30&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;May&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-05-31&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Jun&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-06-30&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Jul&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-07-31&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Aug&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-08-31&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Sep&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-09-30&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Oct&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-10-31&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Nov&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-11-30&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;         &lt;span style=&quot;color: blue&quot;&gt;case &lt;/span&gt;&lt;span style=&quot;color: #a31515&quot;&gt;&quot;Dec&quot;&lt;/span&gt;: varSnapShotDate = &lt;span style=&quot;color: #a31515&quot;&gt;&quot;2011-12-31&quot;&lt;/span&gt;; &lt;span style=&quot;color: blue&quot;&gt;break&lt;/span&gt;;&lt;br /&gt;      }&lt;br /&gt;  Row.SnapshotDate =  varSnapShotDate;&lt;br /&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span &gt;&lt;span &gt;&lt;span&gt;Your SSIS Package data flow tab should look like this. Run the package and query database table&lt;br /&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;* &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;[DBO]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TTB_PRODUCT_SALES]&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span  &gt;).&lt;br /&gt;&lt;/span&gt;&lt;a href=&quot;http://lh5.ggpht.com/-BsE2r9rAkbA/Td15Tarm6TI/AAAAAAAABf4/vBnQm55wAGU/s1600-h/image%25255B62%25255D.png&quot;&gt;&lt;span  &gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;353&quot; alt=&quot;image&quot; src=&quot;http://lh4.ggpht.com/--zVdFrcLuRU/Td15TbAtQVI/AAAAAAAABf8/SPmG6efCPtM/image_thumb%25255B32%25255D.png?imgmax=800&quot; width=&quot;390&quot; border=&quot;0&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/7420121652955086007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/unpivot-data-transformation-in-ssis.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/7420121652955086007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/7420121652955086007'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/unpivot-data-transformation-in-ssis.html' title='Unpivot data transformation in SSIS'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-1a6li249IPA/Td1RGgRzDNI/AAAAAAAABgE/4kjUcoooNJ4/s72-c/image4_thumb%25255B2%25255D.png?imgmax=800" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-5609232431046200160</id><published>2011-05-23T10:58:00.001-07:00</published><updated>2011-05-23T12:14:36.473-07:00</updated><title type='text'>Filter dimension member using MDX VBA function</title><content type='html'>&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;If you are passing month time member in your MDX to slice cube and need to get quarter number for some calculation, you can try something like this. Assume a case where you are showing monthly measure value on the report but the quarterly target. In this case you will need to derive quarter number from month parameter passed in the MDX and define a calculated member for target. &lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Find MDX example below&amp;nbsp; –&lt;/font&gt; &lt;img alt=&quot;&quot; src=&quot;http://em.xjoy.org/i/bubble49.gif&quot;&gt;  &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;WITH &lt;br /&gt;  MEMBER &lt;/span&gt;[INVESTMENT PRODUCT].[PRODUCT NAME].SYKESPRODUCT &lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font size=&quot;2&quot;&gt;AS &lt;br /&gt;    &lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: maroon&quot;&gt;Aggregate&lt;br /&gt;    &lt;/span&gt;(&lt;br /&gt;      {&lt;br /&gt;        &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;Filter&lt;br /&gt;        &lt;/span&gt;(&lt;br /&gt;          &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: maroon&quot;&gt;NonEmpty&lt;br /&gt;          &lt;/span&gt;(&lt;br /&gt;            [INVESTMENT PRODUCT].[PRODUCT NAME].[PRODUCT NAME].&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;MEMBERS&lt;br /&gt;           &lt;/span&gt;,[Measures].[ONCE DONE SURVEYS]&lt;br /&gt;          )&lt;br /&gt;         ,&lt;br /&gt;            VBA!Left&lt;br /&gt;            (&lt;br /&gt;              VBA!Ltrim([INVESTMENT PRODUCT].[PRODUCT NAME].&lt;span style=&quot;color: maroon&quot;&gt;CurrentMember&lt;/span&gt;.&lt;span style=&quot;color: blue&quot;&gt;Name&lt;/span&gt;)&lt;br /&gt;             ,5&lt;br /&gt;            )&lt;br /&gt;          = &quot;SYKES&quot;&lt;br /&gt;        )&lt;br /&gt;      }&lt;br /&gt;    ) &lt;br /&gt;  &lt;span style=&quot;color: blue&quot;&gt;MEMBER &lt;/span&gt;[INVESTMENT PRODUCT].[PRODUCT NAME].OTHERPRODUCT &lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font size=&quot;2&quot;&gt;AS &lt;br /&gt;    &lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: maroon&quot;&gt;Aggregate&lt;br /&gt;    &lt;/span&gt;(&lt;br /&gt;      &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;Filter&lt;br /&gt;      &lt;/span&gt;(&lt;br /&gt;        &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: maroon&quot;&gt;NonEmpty&lt;br /&gt;        &lt;/span&gt;(&lt;br /&gt;          [INVESTMENT PRODUCT].[PRODUCT NAME].[PRODUCT NAME].&lt;span style=&quot;color: blue&quot;&gt;MEMBERS&lt;/span&gt;,&lt;br /&gt;         ,[Measures].[ONCE DONE SURVEYS]&lt;br /&gt;        )&lt;br /&gt;       ,&lt;br /&gt;          VBA!Left&lt;br /&gt;          (&lt;br /&gt;            VBA!Ltrim([INVESTMENT PRODUCT].[PRODUCT NAME].&lt;span style=&quot;color: maroon&quot;&gt;CurrentMember&lt;/span&gt;.&lt;span style=&quot;color: blue&quot;&gt;Name&lt;/span&gt;)&lt;br /&gt;           ,5&lt;br /&gt;          )&lt;br /&gt;        &amp;lt;&amp;gt; &quot;SYKES&quot;&lt;br /&gt;      )&lt;br /&gt;    ) &lt;br /&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;  &lt;/span&gt;{[Measures].[ONCE DONE SURVEYS]} &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;br /&gt; &lt;/span&gt;,{&lt;br /&gt;      {&lt;br /&gt;        [INVESTMENT PRODUCT].[PRODUCT NAME].SYKESPRODUCT&lt;br /&gt;       ,[INVESTMENT PRODUCT].[PRODUCT NAME].OTHERPRODUCT&lt;br /&gt;      }&lt;br /&gt;    * &lt;br /&gt;      [TIME].[YQMD].[Month].&amp;amp;[2010-11-01T00:00:00]&lt;br /&gt;  } &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;ON ROWS&lt;br /&gt;FROM &lt;/span&gt;[YOUR CUBE];&lt;/font&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/5609232431046200160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/filter-dimension-member-using-mdx-vba.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/5609232431046200160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/5609232431046200160'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/filter-dimension-member-using-mdx-vba.html' title='Filter dimension member using MDX VBA function'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-2115176518976558903</id><published>2011-05-19T12:39:00.000-07:00</published><updated>2011-05-23T12:17:39.887-07:00</updated><title type='text'>MDX - Get quarter number from current month time member</title><content type='html'>&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: verdana&quot;&gt;If you are passing month time member in your MDX to slice cube and need to get quarter number for some calculation, you can try something like this. Assume a case where you are showing monthly measure value on the report but the quarterly target. In this case you will need to derive quarter number from month parameter passed in the MDX and define a calculated member for target.&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 10pt; font-family: verdana&quot;&gt;Find MDX example below – &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align: none&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font size=&quot;2&quot;&gt;WITH &lt;br /&gt;  &lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: green&quot;&gt;//Find quarter number from time member&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;MEMBER &lt;/span&gt;MEASURES.[QUARTER NUMBER] &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;br /&gt;    &lt;/span&gt;Cint(Round(&lt;span style=&quot;color: maroon&quot;&gt;YTD&lt;/span&gt;().&lt;span style=&quot;color: blue&quot;&gt;Count &lt;/span&gt;+ 1) / 3) &lt;br /&gt;  &lt;span style=&quot;color: blue&quot;&gt;MEMBER &lt;/span&gt;[Measures].[TARGET VALUE] &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;br /&gt;    &lt;/span&gt;MEASURES.[QUARTER NUMBER] * [Measures].[TARGET] / 4 &lt;br /&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;  &lt;/span&gt;{&lt;br /&gt;    MEASURES.[QUARTER NUMBER]&lt;br /&gt;   ,[Measures].[TARGET VALUE]&lt;br /&gt;  } &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;br /&gt; &lt;/span&gt;,{&lt;span style=&quot;color: maroon&quot;&gt;StrToSet&lt;/span&gt;(@ParamTimeHier)} &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;ON ROWS&lt;br /&gt;FROM &lt;br /&gt;&lt;/span&gt;(&lt;br /&gt;  &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: maroon&quot;&gt;StrToSet&lt;/span&gt;(@ParamTimeHier) &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;ON COLUMNS&lt;br /&gt;  FROM &lt;/span&gt;[YOUR CUBE]&lt;br /&gt;);&lt;/font&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;/p&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/2115176518976558903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/mdx-get-quarter-number-from-current.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/2115176518976558903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/2115176518976558903'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/mdx-get-quarter-number-from-current.html' title='MDX - Get quarter number from current month time member'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-2787092379692519421</id><published>2011-05-19T11:08:00.000-07:00</published><updated>2011-05-23T08:54:37.935-07:00</updated><title type='text'>MDX - Prorating target for current month or quarter</title><content type='html'>&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;In the report, if you need to prorate your measure value based on the month or quarter you are showing, you can do something like the example explained below. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 13px; &quot;&gt;Example. You might get yearly target of say 400 million dollar and based on the quarter you are in, might want prorate the value as under –&lt;/span&gt;&lt;/p&gt;  &lt;table class=&quot;MsoTableGrid&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;margin-left:5.4pt;border-collapse:collapse;border:none;mso-border-alt:  solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;  mso-border-insideh:.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;Quarter   Number&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border:solid windowtext 1.0pt;   border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:   solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;Prorated   $ Value&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:1&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;Quarter   1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border-top:none;border-left:   none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;100&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:2&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;Quarter   2&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border-top:none;border-left:   none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;200&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:3&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;Quarter   3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border-top:none;border-left:   none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;300&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:4;mso-yfti-lastrow:yes&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;Quarter   4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border-top:none;border-left:   none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;400&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 13px; &quot;&gt;MDX snippet –&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align:none;text-autospace:none&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:&amp;quot;Courier New&amp;quot;;color:blue&quot;&gt;WITH&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 13px; &quot;&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color:blue&quot;&gt;MEMBER&lt;/span&gt; MEASURES.MONTHNUMBE &lt;span style=&quot;color:blue&quot;&gt;AS&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 13px; &quot;&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&lt;/span&gt; Month(Cdate(Left(Right(&lt;span style=&quot;color:navy&quot;&gt;[TIME]&lt;/span&gt;.&lt;span style=&quot;color:navy&quot;&gt;[YQMD]&lt;/span&gt;.&lt;span style=&quot;color:blue&quot;&gt;CurrentMember&lt;/span&gt;.&lt;span style=&quot;color:blue&quot;&gt;UniqueName&lt;/span&gt;,&lt;span style=&quot;color:silver&quot;&gt;20&lt;/span&gt;),&lt;span style=&quot;color:silver&quot;&gt;10&lt;/span&gt;)))&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align:none;text-autospace:none&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:&amp;quot;Courier New&amp;quot;&quot;&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color:blue&quot;&gt;MEMBER&lt;/span&gt; MEASURES.PRORATED_TARGET &lt;span style=&quot;color:blue&quot;&gt;AS&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 13px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; CASE&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 13px; &quot;&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&lt;/span&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; WHEN &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 13px; &quot;&gt;MEASURES.MONTHNUMBER = &lt;span class=&quot;Apple-style-span&quot;&gt;1&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 13px; &quot;&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color:blue&quot;&gt;THEN&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; &quot;&gt;&lt;span style=&quot;font-size: 13px; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-size: 13px; color: silver; &quot;&gt;1&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; * &lt;/span&gt;&lt;span style=&quot;font-size: 13px; color: navy; &quot;&gt;[MEASURES]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;font-size: 13px; color: navy; &quot;&gt;[TARGET]&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; / &lt;/span&gt;&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; WHEN &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;MEASURES.MONTHNUMBER = &lt;span style=&quot;color:silver&quot;&gt;4 &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 255); font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;THEN &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;&lt;span style=&quot;color:silver&quot;&gt;2&lt;/span&gt; * &lt;span style=&quot;color:navy&quot;&gt;[MEASURES]&lt;/span&gt;.&lt;span style=&quot;color:navy&quot;&gt;[TARGET]&lt;/span&gt; / &lt;span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;4&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 255); font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;WHEN &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;MEASURES.MONTHNUMBER = &lt;span style=&quot;color:silver&quot;&gt;7 &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 255); font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;THEN &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;&lt;span style=&quot;color:silver&quot;&gt;3&lt;/span&gt; * &lt;span style=&quot;color:navy&quot;&gt;[MEASURES]&lt;/span&gt;.&lt;span style=&quot;color:navy&quot;&gt;[TARGET]&lt;/span&gt; / &lt;span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;4&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 255); font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;ELSE &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;&lt;span style=&quot;color:silver&quot;&gt;4&lt;/span&gt; * &lt;span style=&quot;color:navy&quot;&gt;[MEASURES]&lt;/span&gt;.&lt;span style=&quot;color:navy&quot;&gt;[TARGET]&lt;/span&gt; / &lt;span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;4&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0, 0, 255); font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;END&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot; style=&quot;mso-layout-grid-align:none;text-autospace:none&quot;&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: blue; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt; MEASURES.PRORATED_TARGET&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt; ,MEASURES.MONTHNUMBER&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;} &lt;span style=&quot;color:blue&quot;&gt;ON&lt;/span&gt; COLUMNS&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;,&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 15px; &quot;&gt;NonEmpty&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;  StrToMember(@ParamTime).&lt;span style=&quot;color:blue&quot;&gt;Parent&lt;/span&gt;.&lt;span style=&quot;color:blue&quot;&gt;Lag&lt;/span&gt;(&lt;span style=&quot;color:silver&quot;&gt;3&lt;/span&gt;) : StrToMember(@ParamTime).&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Parent&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt; &lt;/span&gt;,&lt;span style=&quot;color:navy&quot;&gt;[Measures]&lt;/span&gt;.&lt;span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;[TARGET]&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt;&lt;span style=&quot;color:blue&quot;&gt; DIMENSION&lt;/span&gt; &lt;span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;PROPERTIES&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt; MEMBER_CAPTION&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt; ,MEMBER_UNIQUE_NAME&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt; ,PARENT_UNIQUE_NAME&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 14px; &quot;&gt; ,LEVEL_NUMBER&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; &quot;&gt;&lt;span style=&quot;font-size: 14px; color: blue; &quot;&gt;ON&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px;&quot;&gt; ROWS&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:10.0pt;font-family:&amp;quot;Courier New&amp;quot;;color:blue&quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;font-size:10.0pt;font-family:&amp;quot;Courier New&amp;quot;&quot;&gt; &lt;span style=&quot;color:navy&quot;&gt;[YOUR_CUBE]&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;In case of you want your prorating to be done monthly, meaning like –&lt;/span&gt;&lt;/p&gt;  &lt;table class=&quot;MsoTableGrid&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;margin-left:5.4pt;border-collapse:collapse;border:none;mso-border-alt:  solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;  mso-border-insideh:.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;Month   Number&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border:solid windowtext 1.0pt;   border-left:none;mso-border-left-alt:solid windowtext .5pt;mso-border-alt:   solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;Prorated   $ Value&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:1&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;January&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border-top:none;border-left:   none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;1*400/12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:2&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;February&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border-top:none;border-left:   none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;2*400/12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:3&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;…….&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border-top:none;border-left:   none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;---&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:4;mso-yfti-lastrow:yes&quot;&gt;   &lt;td width=&quot;168&quot; valign=&quot;top&quot; style=&quot;width:1.75in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;December&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;   &lt;td width=&quot;204&quot; valign=&quot;top&quot; style=&quot;width:153.0pt;border-top:none;border-left:   none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;   mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;12*400/12&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 13px; &quot;&gt;Replace above calculated member as under -&lt;span style=&quot;mso-spacerun:yes&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;span style=&quot;font-size:10.0pt;font-family:&amp;quot;Courier New&amp;quot;;color:blue&quot;&gt;MEMBER&lt;/span&gt;&lt;span style=&quot;font-size:10.0pt;font-family:&amp;quot;Courier New&amp;quot;&quot;&gt; MEASURES.PRORATED_TARGET &lt;span style=&quot;color:blue&quot;&gt;AS&lt;/span&gt;&lt;span style=&quot;mso-no-proof:yes&quot;&gt;&lt;span style=&quot;mso-tab-count:1&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;; font-size: 13px; &quot;&gt;  &lt;span style=&quot;color:maroon&quot;&gt;YTD&lt;/span&gt;().&lt;span style=&quot;color:blue&quot;&gt;Count&lt;/span&gt;*[Measures].[TPM FY TARGET]/12&lt;/span&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/2787092379692519421/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/mdx-prorating-target-for-current-month.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/2787092379692519421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/2787092379692519421'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/05/mdx-prorating-target-for-current-month.html' title='MDX - Prorating target for current month or quarter'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-2289617014708608051</id><published>2011-02-22T11:09:00.000-08:00</published><updated>2011-05-20T08:17:30.098-07:00</updated><title type='text'>Dynamic Management Views for the Analysis Service Db Monitoring</title><content type='html'>&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana; mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;SQL Server 2008 has some of the cool DMV (Dynamic Management View) which can be used for analysis and monitoring of analysis server databases. You can in fact drill to the details to figure out when the cube and other objects like dimesions, measure groups etc were last processed or modified, whether hierarchy is being used etc.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 14px; &quot;&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana; mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;You can run these DMV’s either in DMX query window or using link server on the relational database query window.&lt;/span&gt;&lt;/p&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana; mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;Here find list of DMV’s and their categories – &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;table class=&quot;MsoTableGrid&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; style=&quot;margin-left:5.4pt;border-collapse:collapse;mso-table-layout-alt:fixed;  border:none;mso-border-alt:solid windowtext .5pt;mso-yfti-tbllook:480;  mso-padding-alt:0in 5.4pt 0in 5.4pt;mso-border-insideh:.5pt solid windowtext;  mso-border-insidev:.5pt solid windowtext&quot;&gt;  &lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;   mso-no-proof:yes&quot;&gt;Analysis Service database Schema &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:1&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DBSCHEMA_CATALOGS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:2&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DBSCHEMA_COLUMNS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:3&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DBSCHEMA_PROVIDER_TYPES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:4&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DBSCHEMA_TABLES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:5&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;   mso-no-proof:yes&quot;&gt;Data Mining Schema&lt;/span&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight:   normal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;mso-bidi-font-family:   &amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:6&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_COLUMNS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:7&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_FUNCTIONS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:8&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_MODEL_CONTENT&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:9&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_MODEL_CONTENT_PMML&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:10&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_MODEL_XML&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:11&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_MODELS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:12&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_SERVICE_PARAMETERS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:13&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_SERVICES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:14&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_STRUCTURE_COLUMNS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:15&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.DMSCHEMA_MINING_STRUCTURES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:16&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;   mso-no-proof:yes&quot;&gt;Meta Data of Analysis Service Database objects like Cube   and ther partitions, Hierarchies etc&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:17&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_CUBES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:18&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_DIMENSIONS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:19&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_FUNCTIONS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:20&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_HIERARCHIES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:21&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_INPUT_DATASOURCES&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:22&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_KPIS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:23&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_LEVELS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:24&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_MEASUREGROUP_DIMENSIONS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:25&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_MEASUREGROUPS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:26&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_MEASURES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:27&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_MEMBERS&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:28&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_PROPERTIES&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=&quot;mso-yfti-irow:29;mso-yfti-lastrow:yes&quot;&gt;   &lt;td width=&quot;576&quot; valign=&quot;top&quot; style=&quot;width:6.0in;border:solid windowtext 1.0pt;   border-top:none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt&quot;&gt;   &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:8.0pt;font-family:Verdana;   mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt;$SYSTEM.MDSCHEMA_SETS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;To run and get audit and monitoring details of Analysis Service Database, say find the details when the cubes were last updated and processed –&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: 14px; &quot;&gt; &lt;/span&gt;&lt;/p&gt;  &lt;ol style=&quot;margin-top:0in&quot; start=&quot;1&quot; type=&quot;1&quot;&gt;  &lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana;mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;      mso-no-proof:yes&quot;&gt;Open Sql Server Management Studio&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;  &lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;span style=&quot;font-size:10.0pt;font-family:Verdana;mso-bidi-font-family:&amp;quot;Courier New&amp;quot;;      mso-no-proof:yes&quot;&gt;Connect to your one of the analysis service database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;Right click on the database name and select DMX query. &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 14px;&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0OcrV2YJ9x7i2b3SE5pkhzhuJ17o90W6Q7WxUTIyqVdCljf4Vz1N9mkvYPYF75FNNBEi8n0aYKbHTdCEGXqxxk_H3WZhB-JZbtPzN_Lt74byFKFVf8jYT2nuYva3SefG6bXfVodYF27w/s400/Image+-+1.JPG&quot; style=&quot;cursor:pointer; cursor:hand;width: 305px; height: 100px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5608817176082020050&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;  &lt;li class=&quot;MsoNormal&quot; style=&quot;mso-list:l0 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;span style=&quot;font-size: 10pt; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;Copy and paste following query in the DMX query window –&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size:10.0pt; font-family:&amp;quot;Courier New&amp;quot;;color:blue;mso-no-proof:yes&quot;&gt;SELECT&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt; * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; color: blue; &quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt; $SYSTEM.MDSCHEMA_CUBES &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; font-size: 10pt; color: blue; &quot;&gt;WHERE&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt; CUBE_SOURCE = 1&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;Find below the result of above query. Only relevant and important columns are included -&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; &quot;&gt;&lt;table class=&quot;MsoNormalTable&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;468&quot; style=&quot;width:351.1pt;margin-left:41.4pt;border-collapse:collapse;mso-padding-alt:  0in 5.4pt 0in 5.4pt&quot;&gt;&lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;border-top:solid windowtext 1.0pt;   border-left:none;border-bottom:solid windowtext 1.0pt;border-right:none;   mso-border-top-alt:solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt;height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;CUBE_NAME&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;border-top:solid windowtext 1.0pt;   border-left:none;border-bottom:solid windowtext 1.0pt;border-right:none;   mso-border-top-alt:solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt;height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;LAST_SCHEMA_UPDATE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;border-top:solid windowtext 1.0pt;   border-left:none;border-bottom:solid windowtext 1.0pt;border-right:none;   mso-border-top-alt:solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .5pt;   padding:0in 5.4pt 0in 5.4pt;height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;center&quot; style=&quot;text-align:center&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;LAST_DATA_UPDATE&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:1;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;Audit&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/20/2011   6:46&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:2;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;Cost Center&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/20/2011   6:46&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:3;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;Dashboard Metrics&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/20/2011   6:46&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:4;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;High Stability&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/20/2011   6:46&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:5;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;Manage Risk&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/20/2011   6:46&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:6;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;Resource Management&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   15:43&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:7;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;SR Practices&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/20/2011   6:46&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:8;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;Superiror Delivery&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/20/2011   6:46&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:9;height:12.75pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;Top Programs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;padding:0in 5.4pt 0in 5.4pt;   height:12.75pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   15:43&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;mso-yfti-irow:10;mso-yfti-lastrow:yes;height:13.5pt&quot;&gt;&lt;td width=&quot;168&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.75in;border:none;   border-bottom:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:13.5pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;   mso-bidi-font-family:Arial&quot;&gt;World Class People&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;144&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:1.5in;border:none;border-bottom:   solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:13.5pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/19/2011   16:01&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width=&quot;156&quot; nowrap=&quot;&quot; valign=&quot;bottom&quot; style=&quot;width:117.1pt;border:none;   border-bottom:solid windowtext 1.0pt;padding:0in 5.4pt 0in 5.4pt;height:13.5pt&quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;right&quot; style=&quot;text-align:right&quot;&gt;&lt;span style=&quot;font-size:9.0pt;font-family:Verdana;mso-bidi-font-family:Arial&quot;&gt;5/20/2011   6:46&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;  &lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; &quot;&gt;Alternatively you can run query connecting to the underline relation database query window. You would need to use link server for query to be able to connect to the analysis service database.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;span class=&quot;Apple-style-span&quot; &gt;Above query can be run in the relation query window –&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px;&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;   &gt;SELECT&lt;/span&gt;&lt;span style=&quot;font-size:10.0pt; font-family:&amp;quot;Courier New&amp;quot;;mso-no-proof:yes&quot;&gt; &lt;span style=&quot;color:gray&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color:blue&quot;&gt;FROM&lt;/span&gt; &lt;span style=&quot;color:blue&quot;&gt;OPENQUERY&lt;/span&gt;&lt;span style=&quot;color:gray&quot;&gt;(YOUR_LINK&lt;/span&gt;_SERVER_NAME&lt;/span&gt;&lt;span style=&quot;font-size:10.0pt; font-family:&amp;quot;Courier New&amp;quot;;color:gray;mso-no-proof:yes&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;font-size:10.0pt;font-family:&amp;quot;Courier New&amp;quot;;color:red;mso-no-proof:yes&quot;&gt;&#39;select * from&lt;span style=&quot;mso-spacerun:yes&quot;&gt;  &lt;/span&gt;$SYSTEM.MDSCHEMA_CUBES WHERE CUBE_SOURCE = 1&#39;&lt;/span&gt;&lt;span style=&quot;font-size:10.0pt;font-family:&amp;quot;Courier New&amp;quot;; color:gray;mso-no-proof:yes&quot;&gt;)&lt;/span&gt;&lt;/p&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/2289617014708608051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/figure-out-when-cube-was-last-processed.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/2289617014708608051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/2289617014708608051'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/figure-out-when-cube-was-last-processed.html' title='Dynamic Management Views for the Analysis Service Db Monitoring'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0OcrV2YJ9x7i2b3SE5pkhzhuJ17o90W6Q7WxUTIyqVdCljf4Vz1N9mkvYPYF75FNNBEi8n0aYKbHTdCEGXqxxk_H3WZhB-JZbtPzN_Lt74byFKFVf8jYT2nuYva3SefG6bXfVodYF27w/s72-c/Image+-+1.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-6855220142064233266</id><published>2011-02-07T11:50:00.000-08:00</published><updated>2011-05-23T12:13:34.424-07:00</updated><title type='text'>Format value using UDF based on format type</title><content type='html'>&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(128,128,128); font-family: verdana&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(0,0,0)&quot;&gt;I encountered a situation where I had to return formatted value to the front end site based on the format type passed. Format type can be dollar ($), number (#) or percentage (%). I am not sure if this is good way to format value based on type passed, but worked for me perfectly –&lt;/span&gt;&lt;font color=&quot;#000000&quot;&gt; &lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt; &lt;p&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;IF &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;EXISTS (&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;* &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;&lt;span style=&quot;color: green&quot;&gt;sys&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: green&quot;&gt;objects &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WHERE &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;object_id &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;OBJECT_ID&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;N&#39;[DW].[fnGetFormattedValue]&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;) AND &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;type &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;in (&lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;N&#39;FN&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;N&#39;IF&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;N&#39;TF&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;N&#39;FS&#39;&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;N&#39;FT&#39;&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;))&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;DROP FUNCTION &lt;/span&gt;[DW]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[fnGetFormattedValue]&lt;br /&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;GO&lt;br /&gt;&lt;br /&gt;CREATE FUNCTION &lt;/span&gt;[DW]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[fnGetFormattedValue]&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;    &lt;/span&gt;@Value &lt;span style=&quot;color: blue&quot;&gt;FLOAT&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;br /&gt;    &lt;/span&gt;@FormatType &lt;span style=&quot;color: blue&quot;&gt;Varchar&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;50&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;RETURNS VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;50&lt;/font&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;font size=&quot;2&quot;&gt;) &lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;AS&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;    DECLARE &lt;/span&gt;@ReturnValue &lt;span style=&quot;color: blue&quot;&gt;VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;100&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;DECLARE &lt;/span&gt;@TempValue &lt;span style=&quot;color: blue&quot;&gt;DECIMAL&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;10&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;2&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SET &lt;/span&gt;@TempValue &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CONVERT &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;DECIMAL&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;10&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;2&lt;span style=&quot;color: gray&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;@Value&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;2&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;))&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SET &lt;/span&gt;@ReturnValue &lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;=&lt;br /&gt;    &lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;CASE &lt;/span&gt;@FormatType &lt;span style=&quot;color: blue&quot;&gt;WHEN &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;$&#39; &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;THEN &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;$&#39; &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;+ &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CAST &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;@TempValue &lt;span style=&quot;color: blue&quot;&gt;AS VARCHAR&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WHEN &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;%&#39; &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;THEN &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CAST &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;@TempValue &lt;span style=&quot;color: blue&quot;&gt;AS VARCHAR&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;) + &lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;%&#39;&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WHEN &lt;/span&gt;&lt;span style=&quot;color: red&quot;&gt;&#39;#&#39; &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;THEN &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CAST &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;@TempValue &lt;span style=&quot;color: blue&quot;&gt;AS VARCHAR&lt;/span&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;ELSE &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;CAST &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;@TempValue &lt;span style=&quot;color: blue&quot;&gt;AS VARCHAR&lt;/span&gt;&lt;/font&gt;&lt;span style=&quot;color: gray&quot;&gt;&lt;font size=&quot;2&quot;&gt;)&lt;br /&gt;    &lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;END&lt;br /&gt;&lt;br /&gt;    RETURN &lt;/span&gt;@ReturnValue&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font size=&quot;2&quot;&gt;END&lt;br /&gt;GO&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/6855220142064233266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/function-format-and-select.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6855220142064233266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6855220142064233266'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/function-format-and-select.html' title='Format value using UDF based on format type'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-3665593199966901690</id><published>2011-02-03T08:25:00.000-08:00</published><updated>2011-05-23T16:38:54.051-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="er"/><title type='text'>SQL find duplicate using Group and Partition By</title><content type='html'>&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;There are various ways to find duplicate records in SQL Server. Like using group and count, partitioning result set etc.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;This article talks about finding duplicate records using two of these methods. I will straight away jump into the SQL example for you to understand easily and quickly.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Create a table name with &lt;strong&gt;[STG].[TMS_TOP_PROGRAMS]&lt;/strong&gt; with following entries into it. This table I have all the programs along with some other attributes like ID, Sort Order etc - &lt;/font&gt;&lt;/p&gt; &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;645&quot; border=&quot;1&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;strong&gt;PROGRAM_ID&lt;/strong&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;strong&gt;PROGRAM_NAME&lt;/strong&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;strong&gt;SORT_ORDER&lt;/strong&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;strong&gt;BATCH_ID&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font size=&quot;2&quot;&gt;11&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Align the Right Customers to the Right Solutions at Optimized cost&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;1&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;11&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Align the Right Customers to the Right Solutions at Optimized cost&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;1&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;12&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Create competitive advantage through business analytics and benchmarking&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;6&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;13&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Deploy future state CSSG operating model&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;2&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;13&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Deploy future state CSSG operating model&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;2&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;14&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Enhance employee engagement&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;7&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;14&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Enhance employee engagement&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;7&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;15&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Expand Direct Sales Capabilities to Grow Revenue&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;3&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;16&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Optimize Service Contacts to Create Sales Opportunities&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;4&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;16&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Optimize Service Contacts to Create Sales Opportunities&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;4&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;17&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Simplify End to End Customer Experience&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;5&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;17&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Simplify End to End Customer Experience&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;5&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;6&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;OpEx Enterprise-Wide Programs&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;6&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;90&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;6&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;392&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;OpEx Enterprise-Wide Programs&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;93&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;6&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;As you see there are lot of duplicate programs in this table. One ways to find duplicate records is by using Group clause as under - &lt;/font&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;br /&gt;    &lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[PROGRAM_NAME]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;KEY_PROGRAM&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;    &lt;/span&gt;SORT_ORDER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt; [BATCH_ID]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;PROGRAM_ID&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;)&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;[STG]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TMS_TOP_PROGRAMS] &lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;GROUP BY &lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[PROGRAM_NAME]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;KEY_PROGRAM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;PROGRAM_SORT_ORDER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[BATCH_ID]&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;HAVING &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;COUNT&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;) &amp;gt; &lt;/span&gt;1&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Another and yet more efficient way to find duplicate by partitioning the table based on the key, here is what I mean..&lt;/font&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[PROGRAM_NAME]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;KEY_PROGRAM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;PROGRAM_SORT_ORDER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[BATCH_ID]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;RANK_ID &lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;FROM&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[PROGRAM_NAME]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;KEY_PROGRAM&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;    &lt;/span&gt;SORT_ORDER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[BATCH_ID]&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;OVER  &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br&gt;       &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;PARTITION BY &lt;/span&gt;PROGRAM_ID &lt;span style=&quot;color: blue&quot;&gt;ORDER BY &lt;/span&gt;PROGRAM_ID&lt;br&gt;    &lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;RANK_ID&lt;br /&gt;    &lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;[STG]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TMS_TOP_PROGRAMS]&lt;br /&gt; &lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;INTBL &lt;span style=&quot;color: blue&quot;&gt;WHERE &lt;/span&gt;RANK_ID &lt;span style=&quot;color: gray&quot;&gt;&amp;gt; &lt;/span&gt;1&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/3665593199966901690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/merge-and-finding-duplicatenot-complete.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/3665593199966901690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/3665593199966901690'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/merge-and-finding-duplicatenot-complete.html' title='SQL find duplicate using Group and Partition By'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-8491955844152208800</id><published>2011-02-02T13:01:00.001-08:00</published><updated>2011-02-02T13:06:19.863-08:00</updated><title type='text'>Filter and Count in MDX</title><content type='html'>&lt;a href=&quot;http://1.bp.blogspot.com/_XGHY31rLQMs/TUnGVpWjk7I/AAAAAAAABJs/_38tvcvuOz0/s1600/table.JPG&quot;&gt;&lt;strong&gt;Filter and Count in MDX&lt;img id=&quot;BLOGGER_PHOTO_ID_5569200489400341426&quot; style=&quot;FLOAT: right; MARGIN: 0px 0px 10px 10px; WIDTH: 200px; CURSOR: hand; HEIGHT: 70px&quot; alt=&quot;&quot; src=&quot;http://1.bp.blogspot.com/_XGHY31rLQMs/TUnGVpWjk7I/AAAAAAAABJs/_38tvcvuOz0/s200/table.JPG&quot; border=&quot;0&quot; /&gt;&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; &lt;/strong&gt;&lt;br /&gt;If you have database table as shown and you requirement is to filter value out before you count the row. In my example, notice the highlighted row,  I got 0 score for those 2 rows and I don&#39;t want such row included when I either create a calculated member in the cube or write report using MDX. In this example I need to get sum of the programs only if score &gt; 0. This is how you the filter condition with count will look -&lt;br /&gt;&lt;strong&gt;MEMBER [Measures].[Program_Count] AS&lt;br /&gt;count (filter([TOP PROGRAMS].[PROGRAM ID].[PROGRAM ID], [Measures].[PROG SCORE]&gt;0))&lt;br /&gt;&lt;/strong&gt;</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/8491955844152208800/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/filter-and-count-in-mdx.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/8491955844152208800'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/8491955844152208800'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/filter-and-count-in-mdx.html' title='Filter and Count in MDX'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_XGHY31rLQMs/TUnGVpWjk7I/AAAAAAAABJs/_38tvcvuOz0/s72-c/table.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-2883653504016943139</id><published>2011-02-02T12:57:00.000-08:00</published><updated>2011-05-23T17:30:22.250-07:00</updated><title type='text'>SQL Insert Update using MERGE</title><content type='html'>&lt;div&gt; &lt;div&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;This will be a very short blog post to help you understand the syntax and usage of Merge SQL statement. I will use same program table (&lt;strong&gt;[STG].[TMS_TOP_PROGRAMS]&lt;/strong&gt;) as source table which I am used in my some of of the other blog posts.&lt;/font&gt;&lt;/div&gt; &lt;div&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;/font&gt;&amp;nbsp;&lt;/div&gt; &lt;div&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;em&gt;MERGE&lt;/em&gt; is very handy when it comes to update or insert using a single SQL statement. In my example I will use &lt;strong&gt;PROGRAM_ID&lt;/strong&gt; to check whether row already exists and if so will update all other attributes else will insert into &lt;strong&gt;[STG].[TMS_TOP_PROGRAMS]&lt;/strong&gt; table.&lt;/font&gt;&lt;/div&gt; &lt;div&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;/font&gt;&amp;nbsp;&lt;/div&gt; &lt;div&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;This is the source table (&lt;strong&gt;[STG].[TMS_TOP_PROGRAMS]&lt;/strong&gt;).&lt;/font&gt;&lt;/div&gt; &lt;div&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;/font&gt;&amp;nbsp;&lt;/div&gt; &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;645&quot; border=&quot;1&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt; &lt;p&gt;PROGRAM_ID&lt;/p&gt;&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;PROGRAM_NAME&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;SORT_ORDER&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;BATCH_ID&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt;11&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;Align the Right Customers to the Right Solutions at Optimized cost - New&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;1&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;100&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt;12&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;Create competitive advantage through business analytics and benchmarking - New&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;6&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;100&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt;13&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;Deploy future state CSSG operating model&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;2&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;100&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt;14&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;Enhance employee engagement - New&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;7&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;100&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt;15&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;Expand Direct Sales Capabilities to Grow Revenue&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;3&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;100&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt;16&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;Optimize Service Contacts to Create Sales Opportunities - New&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;4&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;100&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt;17&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;Simplify End to End Customer Experience&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;5&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;100&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt;6&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;OpEx Enterprise-Wide Programs&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;6&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;100&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;89&quot;&gt;7&lt;/td&gt; &lt;td width=&quot;373&quot;&gt;Enterprise Services&lt;/td&gt; &lt;td width=&quot;113&quot;&gt;8&lt;/td&gt; &lt;td width=&quot;68&quot;&gt;100 &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;div&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;&lt;br&gt;This is how destination table (&lt;strong&gt;[DW].[TMS_DW_TOP_PROGRAMS]&lt;/strong&gt;). Idea is, key from the source table (PROGRAM_ID in my example) will be compared against destination table (PROGRAM_ID column) and if match found a particulate row will be updated else new row will be inserted into the table.&lt;br&gt;&lt;/font&gt;&lt;/div&gt;&lt;/div&gt; &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;651&quot; border=&quot;1&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td width=&quot;98&quot;&gt; &lt;p&gt;&lt;strong&gt;PROGRAM_ID&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt; &lt;td width=&quot;374&quot;&gt;&lt;strong&gt;PROGRAM_NAME&lt;/strong&gt;&lt;/td&gt; &lt;td width=&quot;94&quot;&gt;&lt;strong&gt;SORT_ORDER&lt;/strong&gt;&lt;/td&gt; &lt;td width=&quot;83&quot;&gt;&lt;strong&gt;BATCH_ID&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;100&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;1&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;370&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Organization Alignment&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;96&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;7&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;84&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;101&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;11&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;366&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Align the Right Customers to the Right Solutions at Optimized cost&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;98&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;1&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;85&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;102&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;12&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;363&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Create competitive advantage through business analytics and benchmarking&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;99&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;6&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;86&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;104&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;13&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;360&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Deploy future state CSSG operating model&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;100&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;2&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;86&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;105&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;14&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;358&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Enhance employee engagement&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;101&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;7&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;86&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;105&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;15&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;358&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Expand Direct Sales Capabilities to Grow Revenue&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;102&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;3&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;86&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;105&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;16&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;357&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Optimize Service Contacts to Create Sales Opportunities&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;103&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;4&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;86&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;105&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;17&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;356&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Simplify End to End Customer Experience&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;104&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;5&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;86&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td width=&quot;105&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;6&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;355&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;OpEx Enterprise-Wide Programs&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;105&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;6&lt;/font&gt;&lt;/td&gt; &lt;td width=&quot;86&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;100 &lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Let’s write and check query now. Following query will insert Program ID 7 into destination table as it does not exist and will update all other records from the source. Note that Program ID 1 in the destination table will not have any impact as it is not present in the source.&lt;/font&gt;&lt;/p&gt;&lt;pre class=&quot;code&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;MERGE &lt;/span&gt;[DW]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TMS_DW_TOP_PROGRAMS] &lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;SR&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;USING&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[PROGRAM_NAME]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;KEY_PROGRAM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;SORT_ORDER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[BATCH_ID]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;RANK_ID &lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;FROM&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;SELECT &lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[PROGRAM_NAME]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;KEY_PROGRAM&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;br&gt;    &lt;/span&gt;SORT_ORDER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[BATCH_ID]&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;,&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: magenta&quot;&gt;ROW_NUMBER&lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;OVER &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br&gt;      &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;PARTITION BY &lt;/span&gt;PROGRAM_ID &lt;span style=&quot;color: blue&quot;&gt;ORDER BY &lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;RANK_ID&lt;br /&gt;  &lt;span style=&quot;color: blue&quot;&gt;FROM &lt;/span&gt;[STG]&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[TMS_TOP_PROGRAMS]&lt;br /&gt;&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;INTBL &lt;span style=&quot;color: blue&quot;&gt;WHERE &lt;/span&gt;RANK_ID &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;1&lt;br /&gt;&lt;span style=&quot;color: gray&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;AS &lt;/span&gt;TR&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;ON &lt;/span&gt;SR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;PROGRAM_ID &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;TR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;PROGRAM_ID&lt;br /&gt;&lt;span style=&quot;color: blue&quot;&gt;WHEN &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;MATCHED &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: blue&quot;&gt;THEN &lt;br /&gt;    UPDATE SET &lt;/span&gt;SR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[PROGRAM_NAME] &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;TR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[PROGRAM_NAME]&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;br /&gt;            &lt;/span&gt;SR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;KEY_PROGRAM &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;TR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;KEY_PROGRAM&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;br /&gt;            &lt;/span&gt;SR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;SORT_ORDER &lt;span style=&quot;color: gray&quot;&gt;= &lt;/span&gt;TR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;SORT_ORDER&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;, &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;WHEN &lt;/span&gt;&lt;span style=&quot;color: gray&quot;&gt;NOT MATCHED &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style=&quot;color: blue&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;THEN &lt;br /&gt;    INSERT &lt;/font&gt;&lt;/span&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br&gt;            &lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[PROGRAM_NAME]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;KEY_PROGRAM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;     &lt;br&gt;            PROGRAM_SORT_ORDER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;[BATCH_ID]&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;            )&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;color: blue&quot;&gt;VALUES &lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=&quot;2&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;span style=&quot;color: gray&quot;&gt;(&lt;br&gt;            &lt;/span&gt;TR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;PROGRAM_ID&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;TR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[PROGRAM_NAME]&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;TR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;KEY_PROGRAM&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt; &lt;br&gt;            TR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;PROGRAM_SORT_ORDER&lt;span style=&quot;color: gray&quot;&gt;, &lt;/span&gt;TR&lt;span style=&quot;color: gray&quot;&gt;.&lt;/span&gt;[BATCH_ID]&lt;br&gt;           &lt;span style=&quot;color: gray&quot;&gt;);&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/pre&gt;&lt;a href=&quot;http://11011.net/software/vspaste&quot;&gt;&lt;/a&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/2883653504016943139/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/sql-insert-update-using-merge.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/2883653504016943139'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/2883653504016943139'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/sql-insert-update-using-merge.html' title='SQL Insert Update using MERGE'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-6528182079976550132</id><published>2011-02-01T11:35:00.000-08:00</published><updated>2011-02-01T11:42:06.333-08:00</updated><title type='text'>Null value is eliminated by an aggregate or other SET operation.</title><content type='html'>&lt;strong&gt;Null value is eliminated by an aggregate or other SET operation&lt;/strong&gt;&lt;br /&gt;You get this error while executing SQL statement or stored procedure, if you use aggregate function like sum, max, min etc on a column which contains NULL value.&lt;br /&gt;Example:&lt;br /&gt;SET @METRIC_ID = (SELECT MAX(Convert(int,Metric_ID))+1 from [WEB].[TMS_TOP_PROGRAMS_ENTRY]);&lt;br /&gt;Change above statement with this to get rid of above warning (ANSI):&lt;br /&gt;SET @Metric_ID = (SELECT MAX(Convert(int,isnull(Metric_ID,0)))+1 from [WEB].[TMS_TOP_PROGRAMS_ENTRY]);</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/6528182079976550132/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/warning-null-value-is-eliminated-by.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6528182079976550132'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6528182079976550132'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2011/02/warning-null-value-is-eliminated-by.html' title='Null value is eliminated by an aggregate or other SET operation.'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-3160501593846210885</id><published>2010-07-02T15:44:00.000-07:00</published><updated>2011-05-23T13:12:17.892-07:00</updated><title type='text'>SQL Query - Transaction on DDL</title><content type='html'>&lt;span style=&quot;font-size: 85%&quot;&gt;Execute this.&lt;br&gt;&lt;strong&gt;Begin transaction&lt;br&gt;Create table dbo.t1 (i int);&lt;br&gt;Rollback transaction&lt;/strong&gt;&lt;/span&gt;&lt;br&gt;&lt;span style=&quot;font-size: 85%&quot;&gt;What do you think about the output of following statement?&lt;br&gt;&lt;strong&gt;select * from dbo.t1&lt;/strong&gt;&lt;/span&gt;  </content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/3160501593846210885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2010/07/sql-query-transaction-on-ddl.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/3160501593846210885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/3160501593846210885'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2010/07/sql-query-transaction-on-ddl.html' title='SQL Query - Transaction on DDL'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-19360169646735322</id><published>2010-06-30T08:50:00.000-07:00</published><updated>2010-06-30T08:59:16.957-07:00</updated><title type='text'>SQL Query - You Can (1)</title><content type='html'>&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;I have a table with with entries. &lt;/div&gt;&lt;a href=&quot;http://1.bp.blogspot.com/_XGHY31rLQMs/TCto7fZCi3I/AAAAAAAAAio/i2EM-H3gcB4/s1600/tblConfiguration.JPG&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5488595942129175410&quot; style=&quot;WIDTH: 200px; CURSOR: hand; HEIGHT: 24px&quot; alt=&quot;&quot; src=&quot;http://1.bp.blogspot.com/_XGHY31rLQMs/TCto7fZCi3I/AAAAAAAAAio/i2EM-H3gcB4/s200/tblConfiguration.JPG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;Need to split , separated value to create detail entries like as under &lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://4.bp.blogspot.com/_XGHY31rLQMs/TCtpbX5xAUI/AAAAAAAAAiw/yL4ugRuFEws/s1600/tblConfiDetail.JPG&quot;&gt;&lt;img id=&quot;BLOGGER_PHOTO_ID_5488596489874768194&quot; style=&quot;WIDTH: 200px; CURSOR: hand; HEIGHT: 96px&quot; alt=&quot;&quot; src=&quot;http://4.bp.blogspot.com/_XGHY31rLQMs/TCtpbX5xAUI/AAAAAAAAAiw/yL4ugRuFEws/s200/tblConfiDetail.JPG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/19360169646735322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2010/06/sql-query-you-can-1.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/19360169646735322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/19360169646735322'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2010/06/sql-query-you-can-1.html' title='SQL Query - You Can (1)'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_XGHY31rLQMs/TCto7fZCi3I/AAAAAAAAAio/i2EM-H3gcB4/s72-c/tblConfiguration.JPG" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-419171453207975407</id><published>2010-06-30T08:31:00.000-07:00</published><updated>2011-06-01T11:14:28.334-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Interview"/><title type='text'></title><content type='html'>&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Best practices for designing and developing cubes&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/cc966399.aspx#EDAA&quot;&gt;http://msdn.microsoft.com/en-us/library/cc966399.aspx#EDAA&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;What is Degenerate or junk dimension?&lt;br /&gt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/ms167409.aspx&quot;&gt;http://technet.microsoft.com/en-us/library/ms167409.aspx&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Explain with an example how many-to-many dimension usage &lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;works?&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;What is the use of ADOMD.NET data provider?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;What do you understand by MDX, DMX, ASSL?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;What are the system tables and their usage - sysobject, syscomments?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;When do we execute query using OpenQuery or OpenRowSet command?&lt;br /&gt;&lt;a href=&quot;http://www.sqlyoga.com/2009/04/sql-server-difference-between-openquery.html&quot;&gt;http://www.sqlyoga.com/2009/04/sql-server-difference-between-openquery.html&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;How to process large dimension / cube partition?&lt;br /&gt;&lt;a href=&quot;http://www.artisconsulting.com/blogs/greggalloway/Lists/Posts/Post.aspx?ID=7&quot;&gt;http://www.artisconsulting.com/blogs/greggalloway/Lists/Posts/Post.aspx?ID=7&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;What is the use of AMO (Analysis Management Object)?&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms345084(v=SQL.90).aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms345084(v=SQL.90).aspx&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;In Which Scenarios incremental loading should be done.&lt;br /&gt;&lt;a href=&quot;http://vsteamsystemcentral.com/cs21/blogs/applied_business_intelligence/archive/2007/05/21/ssis-design-pattern-incremental-loads.aspx&quot;&gt;http://vsteamsystemcentral.com/cs21/blogs/applied_business_intelligence/archive/2007/05/21/ssis-design-pattern-incremental-loads.aspx&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Rank() and Partition by in SQL?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Type of slowly changing dimensions?&lt;br /&gt;&lt;a href=&quot;http://www.mssqltips.com/tip.asp?tip=1442&quot;&gt;http://www.mssqltips.com/tip.asp?tip=1442&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Merge or Conditional split to load incremental data?&lt;br /&gt;&lt;a href=&quot;http://consultingblogs.emc.com/jamiethomson/archive/2006/09/12/SSIS_3A00_-Checking-if-a-row-exists-and-if-it-does_2C00_-has-it-changed.aspx&quot;&gt;http://consultingblogs.emc.com/jamiethomson/archive/2006/09/12/SSIS_3A00_-Checking-if-a-row-exists-and-if-it-does_2C00_-has-it-changed.aspx&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Difference between multicast and conditional split tasks?&lt;br /&gt;&lt;a href=&quot;http://consultingblogs.emc.com/jamiethomson/archive/2005/06/11/SSIS_3A00_-Custom-Logging-Using-Event-Handlers.aspx&quot;&gt;http://consultingblogs.emc.com/jamiethomson/archive/2005/06/11/SSIS_3A00_-Custom-Logging-Using-Event-Handlers.aspx&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Event handling in SSIS&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Explain parent-child dimension?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Cube securing without Active Directory.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Report deployment, native mode and share point mode?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Partitioning Strategy for cube&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Should we select materalize in the dimension usage?&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms178448.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms178448.aspx&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;ETL packate configurations and when to use which one?&lt;br /&gt;&lt;a href=&quot;http://www.mssqltips.com/tip.asp?tip=1405&quot;&gt;http://www.mssqltips.com/tip.asp?tip=1405&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Parent and child package variables and call.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;SQL server and file system package deployment&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Execute child pacakge using execute pkg or execute process &lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;tasks?&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;DTEXEC to execute package and various parameters.&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms162810.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/ms162810.aspx&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;How to call package using job?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Managing and running etl packages?&lt;br /&gt;&lt;a href=&quot;http://technet.microsoft.com/en-us/library/cc966389.aspx&quot;&gt;http://technet.microsoft.com/en-us/library/cc966389.aspx&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Create, build and publish reports and model?&lt;br /&gt;&lt;a href=&quot;http://www.accelebrate.com/sql_training/ssrs_2008_tutorial.htm&quot;&gt;http://www.accelebrate.com/sql_training/ssrs_2008_tutorial.htm&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;Report server and report temp db roles?&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:verdana;font-size:85%;&quot;&gt;MDX - Set, tuples, named query etc.&lt;br /&gt;&lt;a href=&quot;http://www.databasejournal.com/features/mssql/article.php/10894_3325131_2/MDX-in-Analysis-Services-Named-Sets-in-MDX-An-Introduction.htm&quot;&gt;http://www.databasejournal.com/features/mssql/article.php/10894_3325131_2/MDX-in-Analysis-Services-Named-Sets-in-MDX-An-Introduction.htm&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-family:Verdana;font-size:85%;&quot;&gt;Handling slowly changing dimension in SSIS if lot of records required to be processed.&lt;br /&gt;&lt;a href=&quot;http://blogs.msdn.com/b/mattm/archive/2009/11/13/handling-slowly-changing-dimensions-in-ssis.aspx&quot;&gt;http://blogs.msdn.com/b/mattm/archive/2009/11/13/handling-slowly-changing-dimensions-in-ssis.aspx&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/419171453207975407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2010/06/best-practices-for-designing-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/419171453207975407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/419171453207975407'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2010/06/best-practices-for-designing-and.html' title=''/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-6986191213070808045</id><published>2009-10-12T06:41:00.001-07:00</published><updated>2009-10-12T06:49:02.992-07:00</updated><title type='text'>Error processing OLAP project</title><content type='html'>If you get this error - &quot;Key not valid for use in specified state&quot;&lt;br /&gt;One probable solution can be to change the a/c under which analysis service is running. I changed from &quot;NT AUTHORITY\LOCAL SERVICE&quot; to &quot;Local Service&quot; a/c and worked for me.</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/6986191213070808045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2009/10/error-processing-olap-project.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6986191213070808045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/6986191213070808045'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2009/10/error-processing-olap-project.html' title='Error processing OLAP project'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-3466204279895601591</id><published>2009-09-22T02:58:00.000-07:00</published><updated>2009-09-22T03:08:53.150-07:00</updated><title type='text'>Figure out whether SSIS package was executed from JOB or not</title><content type='html'>&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Write one SP, like this -&lt;br /&gt;&lt;span style=&quot;color:#3333ff;&quot;&gt;ALTER PROCEDURE [dbo].[RunDTSPackages]&lt;br /&gt;@JobID VARCHAR(255)&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt;SET ROWCOUNT 0&lt;br /&gt;DECLARE @DtexecQuery VARCHAR(8000)&lt;br /&gt;DECLARE @PackageName VARCHAR(200)&lt;br /&gt;DECLARE @DatabaseServer VARCHAR(100)&lt;br /&gt;DECLARE @ID INT&lt;br /&gt;DECLARE @JobSYSID VARCHAR(255)&lt;br /&gt;DECLARE @ReturnCode INT&lt;br /&gt;----my package name to BLANK initially&lt;br /&gt;SET @PackageName = &#39;&#39;&lt;br /&gt;----my server name&lt;br /&gt;SET @DatabaseServer = &#39;F1LT230&#39;&lt;br /&gt;--Passing the SysJobID&lt;br /&gt;SET @JobSYSID =&#39;/set \package.variables[SysJobID].Value;&quot;\&quot;&#39;+@JobId+&#39;\&quot;&quot;&#39;&lt;br /&gt;DECLARE @tblSSISMaster TABLE(&lt;br /&gt;ID INT PRIMARY KEY,&lt;br /&gt;Name VARCHAR(255),&lt;br /&gt;PackageName VARCHAR(255)&lt;br /&gt;)&lt;br /&gt;INSERT @tblSSISMaster SELECT&lt;br /&gt;ID,&lt;br /&gt;Name,&lt;br /&gt;PackageName&lt;br /&gt;FROM SSISPackageToRun&lt;br /&gt;WHERE IsMaster = 1 ORDER BY ID DESC&lt;br /&gt;SET ROWCOUNT 1&lt;br /&gt;SELECT @ID = ID FROM @tblSSISMaster&lt;br /&gt;WHILE @@ROWCOUNT &lt;&gt; 0&lt;br /&gt;BEGIN&lt;br /&gt;SELECT @PackageName = LEFT (PackageName, LEN(PackageName)-5) FROM @tblSSISMaster WHERE ID = @ID&lt;br /&gt;SET @DtexecQuery = &#39;dtexec /sq &#39; + @PackageName + &#39; /ser &#39; + @DatabaseServer + &#39; &#39;&lt;br /&gt;SET @DtexecQuery = @DtexecQuery + @JobSYSID&lt;br /&gt;--Print @DtexecQuery&lt;br /&gt;EXEC @ReturnCode = xp_cmdshell @DtexecQuery&lt;br /&gt;DELETE FROM @tblSSISMaster WHERE ID = @ID&lt;br /&gt;SELECT @ID = ID FROM @tblSSISMaster&lt;br /&gt;END&lt;br /&gt;SET ROWCOUNT 0&lt;br /&gt;END&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Create a job and call above SP as under. Also ensure that you are logging the GUID generated from the job. Also, if same package is being executed from other way - using WEB App or directly, pass a hard coded GUID.&lt;br /&gt;&lt;span style=&quot;color:#3333ff;&quot;&gt;DECLARE @SQL NVARCHAR(72), @jobID UNIQUEIDENTIFIER, @jobName SYSNAME&lt;br /&gt;SET @SQL = &#39;SET @guid = CAST(&#39; + SUBSTRING(APP_NAME(), 30, 34) + &#39; AS UNIQUEIDENTIFIER)&#39;&lt;br /&gt;EXEC sp_executesql @SQL, &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;mailto:N&quot;&gt;&lt;span style=&quot;font-size:85%;color:#3333ff;&quot;&gt;N&#39;@guid&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-size:85%;color:#3333ff;&quot;&gt; UNIQUEIDENTIFIER OUT&#39;, @guid = @jobID OUT&lt;br /&gt;EXEC RunDTSPackages @jobID&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Query the log table for the above two unique GUIDs and get the reports generated as in to know whether the package was executed from the Job or Web.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Your log table should have following columns -&lt;br /&gt;&lt;span style=&quot;color:#3333ff;&quot;&gt;ExecutionLogId]&lt;br /&gt;,[ParentExecutionLogId]&lt;br /&gt;,[Description]&lt;br /&gt;,[PackageName]&lt;br /&gt;,[PackageGuid]&lt;br /&gt;,[MachineName]&lt;br /&gt;,[ExecutionGuid]&lt;br /&gt;,[LogicalDate]&lt;br /&gt;,[Operator]&lt;br /&gt;,[StartTime]&lt;br /&gt;,[EndTime]&lt;br /&gt;,[Status]&lt;br /&gt;,[FailureTask]&lt;br /&gt;,[tblsysJobID]&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;&lt;/span&gt; &lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/3466204279895601591/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2009/09/figure-out-whether-ssis-package-was.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/3466204279895601591'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/3466204279895601591'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2009/09/figure-out-whether-ssis-package-was.html' title='Figure out whether SSIS package was executed from JOB or not'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3560362051436279973.post-3695301856615068260</id><published>2009-09-10T04:39:00.000-07:00</published><updated>2009-09-10T04:59:06.281-07:00</updated><title type='text'>Reporting Service 2008: Call .NET function in MDX</title><content type='html'>&lt;span style=&quot;font-size:85%;&quot;&gt;Steps -&lt;/span&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Create an .NET library. Ensure there is a public function that returns a value - String, Int etc.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Connect to &lt;strong&gt;Analysis Server&lt;/strong&gt; and right click on &lt;strong&gt;Assembly&lt;/strong&gt; folder.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;In the &lt;strong&gt;Register Server Assembly&lt;/strong&gt; window, browse and select the assembly (DLL), created in the step-1. Remove if there is any space in in the &lt;strong&gt;Assembly name&lt;/strong&gt; textbox, you find.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Under the &lt;strong&gt;Permission &lt;/strong&gt;section, select &lt;strong&gt;External access&lt;/strong&gt; and click on OK button.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Notice that the one assemly is added under the &lt;strong&gt;Assembly &lt;/strong&gt;folder.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;In MDX write code as under -&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-size:85%;color:#ff0000;&quot;&gt;MEMBER [Measures].[TECHNOLOGY NAME] AS&lt;br /&gt;(&lt;br /&gt;ITGExecDashboard.GetTechnologyNames ([Measures].[APPLICATION ID])&lt;br /&gt;)&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-size:85%;&quot;&gt;Select above measure in the column. Note that GetTechnologyNames .NET function is being executed and application identifier is being passed which is coming from other measure.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://takeatourtobi.blogspot.com/feeds/3695301856615068260/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://takeatourtobi.blogspot.com/2009/09/reporting-service-2008-call-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/3695301856615068260'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3560362051436279973/posts/default/3695301856615068260'/><link rel='alternate' type='text/html' href='http://takeatourtobi.blogspot.com/2009/09/reporting-service-2008-call-net.html' title='Reporting Service 2008: Call .NET function in MDX'/><author><name>Rajesh</name><uri>http://www.blogger.com/profile/16320550094151917568</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='19' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCEV7-nI72hWZIzhRab3Momqe8HD9d9KfjjUIO23Mk-HnoghU8u7QJFrF7lJDqf3lcq7T_jhXyDKysvMhrFstQWcCE0jBkA3WaWrP9piwkIowQPqz2DIeFeHpfjQUC6g/s220/IMAG0128.jpg'/></author><thr:total>0</thr:total></entry></feed>