<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" >

<channel><title><![CDATA[Microsoft Data & AI - DBA]]></title><link><![CDATA[https://www.delorabradish.com/dba]]></link><description><![CDATA[DBA]]></description><pubDate>Fri, 24 Feb 2023 23:19:15 -0800</pubDate><generator>Weebly</generator><item><title><![CDATA[SQL Server Profiler vs Extended Events for Analysis Services (SSAS) 2016 Database Administration.]]></title><link><![CDATA[https://www.delorabradish.com/dba/sql-server-profiler-2016-vs-extended-events-for-analysis-services-ssas-database-administration]]></link><comments><![CDATA[https://www.delorabradish.com/dba/sql-server-profiler-2016-vs-extended-events-for-analysis-services-ssas-database-administration#comments]]></comments><pubDate>Mon, 06 Mar 2017 14:47:39 GMT</pubDate><category><![CDATA[DBA]]></category><category><![CDATA[Extended Events]]></category><category><![CDATA[SSAS]]></category><guid isPermaLink="false">https://www.delorabradish.com/dba/sql-server-profiler-2016-vs-extended-events-for-analysis-services-ssas-database-administration</guid><description><![CDATA[I recently taught a live webinar for Pragmatic Works on SSAS Monitoring and Performance Tuning with Extended Events. &nbsp;It is worth noting that Profiler is still available to us in SQL Server 2016, and continues to provide benefits that Extended Events do not. &nbsp;This is how I see it.SQL Server Profiler 20161. &nbsp;This very fine SQL Server tool is being deprecated&nbsp;by Microsoft in a later version as stated on MDSN here. &nbsp;The good news is that Profiler is not deprecated quite yet [...] ]]></description><content:encoded><![CDATA[<div class="paragraph"><font color="#2a2a2a">I recently taught a live webinar for Pragmatic Works on </font><u><a href="http://pragmaticworks.com/Training/Details/SSAS-2016-Monitoring-and-Performance-Tuning-with-Extended-Events" target="_blank"><font color="#e0915c">SSAS Monitoring and Performance Tuning with Extended Events</font></a></u><font color="#2a2a2a">. &nbsp;It is worth noting that Profiler is still available to us in SQL Server 2016, and continues to provide benefits that Extended Events do not. &nbsp;This is how I see it.</font><br /><br /><font color="#c2743b"><strong>SQL Server Profiler 2016</strong></font><br /><font color="#2a2a2a">1. &nbsp;This very fine SQL Server tool is being deprecated&nbsp;by Microsoft in a later version as stated on MDSN </font><u><a href="https://msdn.microsoft.com/en-us/library/ms143729.aspx" target="_blank"><font color="#e0915c">here</font></a></u><font color="#2a2a2a">. &nbsp;The good news is that Profiler is not deprecated quite yet. &nbsp;Hooray!</font><br /><br /><font color="#2a2a2a">2. &nbsp;This is still the fastest way to log SSAS query activity for immediate analysis. &nbsp;You do not need to write out to a file, view said file, and import. &nbsp;SQL Profiler provides a very handy viewing tool that is real time. &nbsp;When needing to complete a one-off monitoring of a problematic query, SSIS package or SSRS report, this is the low hanging fruit.</font><br /><br /><font color="#2a2a2a">3. &nbsp;Granted, Profiler has a heavier "footprint" than Extended Events (i.e. it takes more system resources). Coupled with the fact that it is going away ... eventually ... it should not be considered as a long-term monitoring tool of choice. &nbsp;When I say "long term monitoring" I am referring to scheduling monitoring through a SSIS package.</font><br /><br /><font color="#2a2a2a">4. &nbsp;When working with Profiler and SSAS, it is important to </font><strong style="color:rgb(42, 42, 42)">Show All Properties</strong><font color="#2a2a2a"> on the </font><strong style="color:rgb(42, 42, 42)">Events Selection</strong><font color="#2a2a2a"> tab of the </font><strong style="color:rgb(42, 42, 42)">Trace Properties</strong><font color="#2a2a2a"> window and mark relevant SSAS events. &nbsp;Not all SSAS events are marked by default when connecting to a SSAS instance and taking the default SSAS trace. &nbsp;The list of tabular and multidimensional events I use most often is given below.</font><br /><br /><strong><font color="#c2743b">Extended Events (EE) in SQL Server 2016</font></strong><br /><font color="#2a2a2a">&#8203;1. &nbsp;It is sometimes misunderstood, but EE is not a new SQL 2016 SSAS feature. &nbsp;You could use XMLA in earlier SQL Server versions. &nbsp;Chris Webb has a very good BI Blog post </font><u><a href="https://blog.crossjoin.co.uk/2012/05/05/using-xevents-in-ssas-2012/" target="_blank"><font color="#e0915c">here</font></a></u><font color="#2a2a2a"> that talks about doing this very thing in SQL 2012.</font><br /><br /><font color="#2a2a2a">2. &nbsp;What is new in SQL 2016 is the user interface for creating SSAS EE sessions. &nbsp;Unfortunately, I feel that Microsoft did a half-hearted effort in this, and that is the politically correct way of saying it. &nbsp;In a SSAS instance, you can </font><em style="color:rgb(42, 42, 42)">create</em><font color="#2a2a2a"> EE sessions, but you </font><em style="color:rgb(42, 42, 42)">cannot edit</em><font color="#2a2a2a"> them. &nbsp;For real? &nbsp;The solution is to use the GUI to setup the session, then be sure to script it out before you save it. &nbsp;</font><br /><br /><font color="#2a2a2a">3. &nbsp;When working with EE for SSAS, I recommend you use a XMLA query in SQL Server Management Studio&nbsp;(SSMS). &nbsp;Attached to this post is the XMLA for creatings, stopping, deleting and querying current EE sessions for both tabular models and multidimensional cubes.<br /><br />4. &nbsp;If using EE to warm your SSAS multidimensional cube cache, or to monitor user query durations and execution counts, EE and SSIS is definitely the best solution. &nbsp;Use a SSIS package on a scheduled job to automatically stop, import and restart EE sessions. &nbsp;Use t-sql against the resulting SQL Server database table, and SSRS to automatically report long running queries.</font><br /><br /><font color="#c2743b"><strong>Profile Trace / Extended Events SSAS Events:</strong></font><br /><font color="#2a2a2a">This is not a complete listing, but these are the events that I find most helpful when monitoring SSAS.</font><br /><font color="#da8044">Multidimensional</font><br /><font color="#2a2a2a">&nbsp; &nbsp; ExecuteMDXScriptEnd</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;GetDataFromAggregations</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;GetDataFromCache</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;ProgressReportEnd</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;QueryCubeEnd</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;QueryEnd</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;QuerySubcube</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;QuerySubcubeVerbose</font><br /><br /><font color="#da8044">Tabular</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;DAXQueryPlan</font><br /><font color="#2a2a2a">&nbsp; &nbsp; QueryCubeEnd</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;QueryEnd</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;QueryExceedsMemoryLimit</font><br /><font color="#2a2a2a">&nbsp;&nbsp; &nbsp;VertiPaqSEQueryEnd (using the VertiPaq Scan subclass event)</font><br /><br /><font color="#a85f2e"><strong>XMLA File Downloads</strong></font></div>  <div><div style="margin: 10px 0 0 -10px"> <a href="https://www.delorabradish.com/uploads/5/3/4/3/53431729/dba_create_stop_delete_xevents_for_multid_cubes.xmla"><img src="//www.weebly.com/weebly/images/file_icons/file.png" width="36" height="36" style="float: left; position: relative; left: 0px; top: 0px; margin: 0 15px 15px 0; border: 0;" /></a><div style="float: left; text-align: left; position: relative;"><table style="font-size: 12px; font-family: tahoma; line-height: .9;"><tr><td colspan="2"><b> dba_create_stop_delete_xevents_for_multid_cubes.xmla</b></td></tr><tr style="display: none;"><td>File Size:  </td><td>4 kb</td></tr><tr style="display: none;"><td>File Type:  </td><td> xmla</td></tr></table><a href="https://www.delorabradish.com/uploads/5/3/4/3/53431729/dba_create_stop_delete_xevents_for_multid_cubes.xmla" style="font-weight: bold;">Download File</a></div> </div>  <hr style="clear: both; width: 100%; visibility: hidden"></hr></div>  <div><div style="margin: 10px 0 0 -10px"> <a href="https://www.delorabradish.com/uploads/5/3/4/3/53431729/dba_create_stop_delete_xevents_for_tabular_models.xmla"><img src="//www.weebly.com/weebly/images/file_icons/file.png" width="36" height="36" style="float: left; position: relative; left: 0px; top: 0px; margin: 0 15px 15px 0; border: 0;" /></a><div style="float: left; text-align: left; position: relative;"><table style="font-size: 12px; font-family: tahoma; line-height: .9;"><tr><td colspan="2"><b> dba_create_stop_delete_xevents_for_tabular_models.xmla</b></td></tr><tr style="display: none;"><td>File Size:  </td><td>2 kb</td></tr><tr style="display: none;"><td>File Type:  </td><td> xmla</td></tr></table><a href="https://www.delorabradish.com/uploads/5/3/4/3/53431729/dba_create_stop_delete_xevents_for_tabular_models.xmla" style="font-weight: bold;">Download File</a></div> </div>  <hr style="clear: both; width: 100%; visibility: hidden"></hr></div>]]></content:encoded></item><item><title><![CDATA[Columnstore Index POC]]></title><link><![CDATA[https://www.delorabradish.com/dba/columnstore-index-poc]]></link><comments><![CDATA[https://www.delorabradish.com/dba/columnstore-index-poc#comments]]></comments><pubDate>Thu, 25 Jun 2015 07:21:11 GMT</pubDate><category><![CDATA[Columnstore]]></category><category><![CDATA[DBA]]></category><category><![CDATA[Indexing]]></category><category><![CDATA[Performance]]></category><guid isPermaLink="false">https://www.delorabradish.com/dba/columnstore-index-poc</guid><description><![CDATA[To prove out SQL Server&rsquo;s columnstore capabilities, I wanted to set up my own POC (proof of concept).&nbsp; I found, however, that to do this, I needed a more fundamental understanding of how and when SQL Server actually took advantage of the benefits of columnstore.&nbsp; So having worked through this for myself, I thought I&rsquo;d document my Columnstore POC for you.&nbsp; The purpose of the article is to help you setup your own POC so you can test this out for yourself with your own da [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font color="#2a2a2a">To prove out SQL Server&rsquo;s columnstore capabilities, I wanted to set up my own POC (proof of concept).&nbsp; I found, however, that to do this, I needed a more fundamental understanding of how and when SQL Server actually took advantage of the benefits of columnstore.&nbsp; So having worked through this for myself, I thought I&rsquo;d document my Columnstore POC for you.&nbsp; <strong style="">The purpose of the article is to help you setup your own POC so you can test this out for yourself with your own data</strong> &ndash; the intent is not to explain columnstore in general.<br /><span style=""></span><br /><span style=""></span>    First, to setup your POC, make sure your data store and t-SQL meet these qualifications:<br />1.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Have at least one FACT table with at least 100 million rows.&nbsp; I setup the following:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Four fact tables with identical values with 100.2 million rows each<br /><span "font-family:wingdings;mso-fareast-font-family:wingdings;mso-bidi-font-family:="" wingdings"="" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&sect;<span style="">&nbsp; </span></span>A heap table with no indexes or keys &ndash; created for the sake of example<br /><span style=""></span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span "font-family:wingdings;mso-fareast-font-family:wingdings;mso-bidi-font-family:="" wingdings"="" style="">&sect;<span style="">&nbsp; </span></span>An indexed table with a clustered PK, but no columnstore&nbsp;</font><br /><font color="#2a2a2a">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&ndash; a common SQL 2008 R2 data warehouse scenario<br /><span "font-family:wingdings;mso-fareast-font-family:wingdings;mso-bidi-font-family:="" wingdings"="" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&sect;<span style="">&nbsp; </span></span>A non-clustered columnstore indexed table which included all columns &ndash; a SQL 2012 scenario<br /><span "font-family:wingdings;mso-fareast-font-family:wingdings;mso-bidi-font-family:="" wingdings"="" style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &sect;<span style="">&nbsp; </span></span>A clustered columnstore indexed table which included all columns &ndash; a SQL 2014 scenario<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>One degenerate dimension table containing a clustered PK.&nbsp;&nbsp;</font><br /><font color="#2a2a2a">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; This table had a 1-1 relationship with my fact table.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Two dimension tables containing a clustered PK, one being a date or calendar table.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</font><br /><font color="#2a2a2a">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; In the end, my table list was as follows &hellip;</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-thick " style="padding-top:0;padding-bottom:0;margin-left:15px;margin-right:0;text-align:left"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/8836918_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a"><font size="2">&nbsp; &nbsp; &nbsp; &nbsp;NoCSI = No clustered columnstore index (clustered PK)<br />&nbsp; &nbsp; &nbsp; &nbsp;WithCCSI = With clustered columnstore index (no PK)<br />&nbsp; &nbsp; &nbsp; &nbsp;WithNCCSI = With non-clustered columnstore index (no PK)</font><br /><span style=""></span><br /><span style=""></span>&nbsp; &nbsp; &nbsp; &hellip; and my indexes were as follows:</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:15px;margin-right:0;text-align:left"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/6120658_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">2.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="#2a2a2a">Understand that a clustered Columnstore index is the primary storage for the entire table.&nbsp; A nonclustered Columnstore (NCCS) index is a secondary index.&nbsp; A table with a NCCS is actually a rowstore table and the index is a copy of the rows and columns in the table.</font><br /><br /><font color="#2a2a2a">3.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="#2a2a2a">Model your POC in a proper star schema using integer data types for PKs and SKs etc.</font><br /><br /><font color="#2a2a2a">4.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="#2a2a2a">To test Columnstore, your t-sql must use an aggregate, like SUM() or COUNT(), a GROUP BY and preferably an ORDER BY</font><br /><br /><font color="#2a2a2a">5.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="#2a2a2a">To test segment elimination, use a WHERE clause that will pull back only a subset of data&nbsp;</font><br /><br /><font color="#2a2a2a">6.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="#2a2a2a">To take advantage of batch mode query processing, your t-SQL should use INNER JOINS, not LEFT OUTER or OUTER joins.&nbsp; This was true in SQL Server 2012.&nbsp; I could not replicate the &lsquo;Row&rsquo; Actual Execution Mode in SQL Server 2014.</font><br /><br /><font color="#2a2a2a">7.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="#2a2a2a">This might seem obvious, but make sure you are working in the SQL server 2014 version of SSMS (SQL Server Management Studio).&nbsp; You can actually create a clustered Columnstore index in SQL 2012 SSMS on a table stored on a SQL 2014 instance, but it just gets confusing because the SQL 2012 GUI won&rsquo;t visually indicate it.</font><br /><br /><strong style="color: rgb(42, 42, 42);">When you think you are ready to go, double check your table design and data by running some system views.</strong><br /><br /><font color="#2a2a2a">1.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font color="#2a2a2a">Verify that Columnstore indexes really exist.</font><br /><font color="#da8044" size="2"><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SELECT</span>&nbsp;distinct&nbsp;t.name<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FROM</span>&nbsp;sys.column_store_row_groups csrg<br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LEFT</span>&nbsp;JOIN sys.tables t on csrg.object_id = t.object_id</font><br /></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:15px;margin-right:0;text-align:left"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/4953904_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">2.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><font color="#2a2a2a">Verify that your fact tables contain the same number of rows.&nbsp; You can do this a couple of ways.</font><br /><font color="#2a2a2a">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><font color="#2a2a2a">Script to select table metadata</font><br /><font color="#da8044"><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<font size="2">SELECT</font></span><font size="2"><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tbl_ObjectID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="">=</span> t<span style="">.</span><span style="">object_id</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>tbl_SchemaName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="">=</span> s<span style="">.</span>name<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>tbl_TableName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="">=</span> t<span style="">.</span>name<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="">,</span>tbl_TableType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="">=</span> t<span style="">.</span><span style="">type</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="">,</span>tbl_TableTypeDescr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="">=</span> t<span style="">.</span>type_desc<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>tbl_DateCreated&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="">=</span> create_date<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>tbl_RowCount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="">=</span> si<span style="">.</span>rowcnt<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>tbl_ColumnCount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="">=</span> c<span style="">.</span>ColumnCount<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FROM</span> <span style="">sys</span><span style="">.</span><span style="">tables</span> t <span style="">WITH </span><span style="">(</span><span style="">NOLOCK</span><span style="">)</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LEFT</span> <span style="">JOIN</span> <span style="">sys</span><span style="">.</span><span style="">schemas</span> s <span style="">WITH </span><span style="">(</span><span style="">NOLOCK</span><span style="">)</span> <span style="">on</span> t<span style="">.</span><span style="">schema_id</span> <span style="">=</span> s<span style="">.</span><span style="">schema_id</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LEFT</span> <span style="">JOIN</span> <span style="">sys</span><span style="">.</span><span style="">sysindexes</span> si <span style="">WITH </span><span style="">(</span><span style="">NOLOCK</span><span style="">)</span> <span style="">on</span> t<span style="">.</span><span style="">object_id</span> <span style="">=</span> si<span style="">.</span>id<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="">AND</span> si<span style="">.</span>indid <span style="">&lt;</span> 2 <br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LEFT</span> <span style="">JOIN</span><span style=""> </span><span style="">(</span><span style="">SELECT</span> <span style="">object_id</span><span style="">,</span> <span style="">COUNT</span><span style="">(*)</span> <span style="">as</span> ColumnCount <span style="">from</span> <span style="">sys</span><span style="">.</span><span style="">columns</span> c <span style="">group</span> <span style="">by</span> c<span style="">.</span><span style="">object_id</span><span style="">)</span> c<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; on t.object_id = c.object_id</font></font><br /><font color="#2a2a2a">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;b.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><font color="#2a2a2a">Script to get space used</font><br /><font color="#da8044"><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <font size="2">exec</font></span><font size="2"> <span style="">sp_spaceused</span><span style=""> </span><span style="">'[dbo].[FactTransactionsHeap]'</span><span style="">,</span> true<span style="">;</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exec</span> <span style="">sp_spaceused</span><span style=""> </span><span style="">'[dbo].[FactTransactionsNoCSI]'</span><span "color:="" gray"="" style="">,</span> true<span style="">;</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exec</span> <span style="">sp_spaceused</span><span style=""> </span><span style="">'[dbo].[FactTransactionsWithCCSI]'</span><span style="">,</span> true<span style="">;</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exec</span> sp_spaceused '[dbo].[FactTransactionsWithNCCSI]', true;</font></font><br /><font color="#2a2a2a"><span style=""></span></font><br /><font color="#2a2a2a"><span style=""></span>    Before we start testing for query performance, also take a look at the space used.&nbsp; It should come as no surprise that the clustered columnstore table uses 32% less space than the other tables.</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/9215742_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">You can read about sp_spaceused on MSDN here</font> (<a href="https://msdn.microsoft.com/en-us/library/ms188776.aspx" style="" title="">https://msdn.microsoft.com/en-us/library/ms188776.aspx</a><font color="#2a2a2a">), but a brief explanation is as follows:<br /><span "font-family:symbol;mso-fareast-font-family:symbol;mso-bidi-font-family:="" symbol"="" style="">&middot;<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><strong style="">Reserved</strong> is the total amount of space allocated by objects in the database<br /><span "font-family:symbol;mso-fareast-font-family:symbol;mso-bidi-font-family:="" symbol"="" style="">&middot;<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><strong style="">Data</strong> is the total amount of space used by data<br /><span "font-family:symbol;mso-fareast-font-family:symbol;mso-bidi-font-family:="" symbol"="" style="">&middot;<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><strong style="">Index_size</strong> is the total amount of space used by index<br /><span "font-family:symbol;mso-fareast-font-family:symbol;mso-bidi-font-family:="" symbol"="" style="">&middot;<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><strong style="">Unused</strong> is the total amount of space reserved for objects in the database, but not yet used.<br /><span style=""></span><br /><span style=""></span>  Nicely formatted, our test data looks like this:</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/9430795_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">Now for the good stuff!&nbsp; Let&rsquo;s write a typical OLAP query and run it against each fact table recording execution times.</font><br /><font color="#da8044" size="2"><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">SET</span> <span style="">STATISTICS</span> <span style="">TIME</span> <span style="">ON</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">GO</span><span style=""></span><br /><br /><span style=""></span>  <span "font-size:9.5pt;font-family:consolas;="" color:blue"="">SELECT</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp; c<span style="">.</span>cal_Year<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>i<span style="">.</span>itm_Code<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span><span style="">SUM</span><span style="">(</span>trn_NetAmt<span style="">)</span> <span style="">as</span> SumOfNetAmt<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">FROM</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp;dbo<span style="">.</span>FactTransactionsHeap t<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">--dbo.FactTransactionsNoCSI t</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">--dbo.FactTransactionsWithCCSI t</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">--dbo.FactTransactionsWithNCCSI t</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimCalendar c <span style="">on</span> t<span style="">.</span>trn_TransDateSK <span style="">=</span> c<span style="">.</span>cal_DateIntPK<br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimITem i <span style="">on</span> t<span style="">.</span>trn_ItemSK <span style="">=</span> i<span style="">.</span>itm_PK<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">GROUP</span> <span style="">BY</span> c<span style="">.</span>cal_Year<span style="">,</span> i<span style="">.</span>itm_Code<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">ORDER</span> BY i.itm_Code, c.cal_Year</font><br /><br /><font color="#2a2a2a"><span style=""></span>  Returning 177,099 aggregated rows, these were my execution times:</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/9217697_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a"><strong>Before moving on to add a WHERE clause, let&rsquo;s take a look at our query execution plans.</strong><br /><br /></font><font color="#2a2a2a"><span id="selectionBoundary_1435215450867_562868595123291" class="rangySelectionBoundary" style="line-height: 0; display: none;">&#65279;</span>As expected, our heap table used a table scan.<span id="selectionBoundary_1435215450867_6697368621826172" class="rangySelectionBoundary" style="line-height: 0; display: none;">&#65279;</span></font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-thick " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/8245874_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><br /><br /><font color="#2a2a2a">Our table with only a clustered PK (our SQL 2008 R2 scenario) used a clustered index scan.</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-thick " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/1507616_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><br /><br /><font color="#2a2a2a">Our table with a non-clustered Columnstore index (our SQL 2012 scenario) used a Columnstore index scan.</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-thick " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/8056512_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><br /><br /><font color="#2a2a2a">We have almost identical results with our clustered Columnstore indexed table (our SQL 2014 scenario).</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-thick " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/1849379_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><br /><br /><font color="#2a2a2a">Let&rsquo;s take this one step further.&nbsp; Hover your mouse over your Columnstore Index Scan operator.&nbsp; If your query is optimized, your <strong style="">Actual Execution Mode</strong> should say &lsquo;Batch&rsquo;.</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/6925879_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><font color="#2a2a2a">This is a fundamental principle of query performance.&nbsp; You want SQL Server to use &lsquo;Batch&rsquo; mode vs &lsquo;Row&rsquo; mode as much as possible.&nbsp; If you look under your Heap or NoCSI scan operators, you will see that they are using a &lsquo;Row&rsquo; <strong style="">Actual Execution Mode</strong> &hellip; and therefore they take longer to execute.<br /><span style=""></span><br /><span style=""></span>    Okay, now let&rsquo;s add a WHERE clause as 99% of the OLAP queries I have seen want to filter or slice on some sort of date value.&nbsp; We should also talk about segment elimination, which you can read up from TechNet here --&gt;&nbsp;</font>(<a href="http://social.technet.microsoft.com/wiki/contents/articles/5651.understanding-segment-elimination.aspx" style="" title="">http://social.technet.microsoft.com/wiki/contents/articles/5651.understanding-segment-elimination.aspx</a>).<br /><span style=""></span><br /><span style=""></span>    <font color="#2a2a2a">The short version is SQL Server segments columnstore columns in groups of roughly 1 million rows.&nbsp; Metadata associated with each segment exposes a MAX and MIN value of each segment.&nbsp; So when you filter on DimDate.DateKey between [x] and [y], SQL Server will look at the segment metadata and automatically skip past those segments that do not contain qualifying column values.&nbsp; An example of how to verify columnstore segment elimination can be found here --&gt;&nbsp;</font>(<a href="http://social.technet.microsoft.com/wiki/contents/articles/5611.verifying-columnstore-segment-elimination.aspx" style="" title="">http://social.technet.microsoft.com/wiki/contents/articles/5611.verifying-Columnstore-segment-elimination.aspx</a>) <font color="#2a2a2a">but for our purposes, let&rsquo;s have an element of trust and look at our execution results from a filtered query.<br /><span style=""></span><br /><span style=""></span>    First, let&rsquo;s take a look to see what we have to work with.</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-thick " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/1480431_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">Next, let&rsquo;s build a query.</font><br /><font color="#da8044" size="2"><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">SELECT</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp; c<span style="">.</span>cal_Year<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>i<span style="">.</span>itm_Code<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span><span style="">SUM</span><span style="">(</span>trn_NetAmt<span style="">)</span> <span style="">as</span> SumOfNetAmt<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">FROM</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">--dbo.FactTransactionsHeap t</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">--dbo.FactTransactionsNoCSI t</span><br />&nbsp; &nbsp; &nbsp; &nbsp;dbo<span style="">.</span>FactTransactionsWithCCSI t<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">--dbo.FactTransactionsWithNCCSI t</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimCalendar c <span style="">on</span> t<span style="">.</span>trn_TransDateSK <span style="">=</span> c<span style="">.</span>cal_DateIntPK<br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimITem i <span style="">on</span> t<span style="">.</span>trn_ItemSK <span style="">=</span> i<span style="">.</span>itm_PK<br /><strong><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">WHERE</span> t<span style="">.</span>trn_TransDateSK <span style="">Between</span> 20060101 <span style="">and</span> 20121231</strong><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">GROUP</span> <span style="">BY</span> c<span style="">.</span>cal_Year<span style="">,</span> i<span style="">.</span>itm_Code<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">ORDER</span> BY i.itm_Code, c.cal_Year</font><br /><br /><font color="#2a2a2a">Returning 93,469 aggregated rows, these were my execution times:</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/4834003_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">A quick note about our &lsquo;Heap&rsquo; table and the &lsquo;NoCSI&rsquo; table which contained a clustered primary key.&nbsp; How many times have you heard the phrase &ldquo;index lite&rdquo;?&nbsp; We have a clustered PK on our FactTransactionsNoCSI and our one-to-one degenerate dimension DimTransactions to support that relationship, but notice how the &lsquo;Heap&rsquo; table actually had better query performance.<br /><span style=""></span><br /><span style=""></span>    It is only fair that we take a minute to demo a couple of anti-performance practices given to TechNet&rsquo;s SQL Server Columnstore Performance Tuning article found here --&gt; &nbsp;</font>(<a href="http://social.technet.microsoft.com/wiki/contents/articles/4995.sql-server-columnstore-performance-tuning.aspx" style="" title="">http://social.technet.microsoft.com/wiki/contents/articles/4995.sql-server-Columnstore-performance-tuning.aspx</a>)<br /><font color="#2a2a2a">1.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><font color="#2a2a2a">String Filters</font><br /><font color="#2a2a2a">2.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><font color="#2a2a2a">OUTER JOINS</font><br /><font color="#2a2a2a">3.</font><span style="color: rgb(42, 42, 42);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><font color="#2a2a2a">Joining to an equally large DegenerateDim table that does not have a columnstore index</font><br /><font color="#2a2a2a"><span style=""></span></font><br /><font color="#2a2a2a"><span style=""></span>    Here is our t-SQL where we are just wanting OPEN status transactions</font><br /><font color="#da8044" size="2"><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">SELECT</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp; c<span style="">.</span>cal_Year<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>i<span style="">.</span>itm_Code<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span><span style="">SUM</span><span style="">(</span>trn_NetAmt<span style="">)</span> <span style="">as</span> SumOfNetAmt<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">FROM</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp;dbo<span style="">.</span>FactTransactionsWithCCSI t<br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimCalendar c <span style="">on</span> t<span style="">.</span>trn_TransDateSK <span style="">=</span> c<span style="">.</span>cal_DateIntPK<br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimITem i <span style="">on</span> t<span style="">.</span>trn_ItemSK <span style="">=</span> i<span style="">.</span>itm_PK<br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimTransactions dt <span style="">on</span> t<span style="">.</span>trn_PK <span style="">=</span> dt<span style="">.</span>trn_PK<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">WHERE</span> t<span style="">.</span>trn_TransDateSK <span style="">Between</span> 20060101 <span style="">and</span> 20121231<br /><strong>&nbsp;&nbsp;<span "color:gray;background:yellow;="" mso-highlight:yellow"="" style="">and</span><span "background:yellow;mso-highlight:="" yellow"="" style=""> dt<span style="">.</span>trn_StatusCode <span style="">&lt;&gt;</span> <span style="">'CLOSED'</span></span></strong><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">GROUP</span> <span style="">BY</span> c<span style="">.</span>cal_Year<span style="">,</span> i<span style="">.</span>itm_Code<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">ORDER</span> BY i.itm_Code, c.cal_Year</font><br /><font color="#2a2a2a"><span style=""></span></font><br /><font color="#2a2a2a"><span style=""></span>    Here is our query execution plan where our filter cost is 86% of our total execution time.&nbsp; Note the &lsquo;Row&rsquo; </font><strong style="color: rgb(42, 42, 42);">Actual Execution Mode</strong><font color="#2a2a2a">.</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/2649903_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">The case can be made that this is expected behavior and not the fault of our fact table columnstore index, and that is correct as we are filtering on DimTransactions which does not have a columnstore.&nbsp; Let&rsquo;s put a columnstore index on DimTransaction as it does have as many rows as our fact table, and see what happens.</font><br /><font color="#2a2a2a"><span style=""></span></font><br /><span style=""></span>    <font color="#da8044"><font size="2"><span "font-size:9.5pt;font-family:consolas;="" color:blue"=""><span id="selectionBoundary_1435216423496_6789207458496094" class="rangySelectionBoundary" style="line-height: 0; display: none;">&#65279;</span>CREATE</span> <span style="">TABLE</span> [dbo]<span style="">.</span>[DimTransactionsWithCCSI]<span style="">(</span><br />&nbsp; &nbsp; &nbsp; &nbsp;[trn_PK] [int] <span style="">NOT</span> <span style="">NULL,</span><br />&nbsp; &nbsp; &nbsp; &nbsp;[trn_No] [int] <span style="">NOT</span> <span style="">NULL,</span><br />&nbsp; &nbsp; &nbsp; &nbsp;[trn_SeqNo] [int] <span "color:="" gray"="" style="">NOT</span> <span style="">NULL,</span><br />&nbsp; &nbsp; &nbsp; &nbsp;[trn_SourceCode] [varchar]<span style="">(</span>50<span style="">)</span> <span style="">NOT</span> <span style="">NULL,</span><br />&nbsp; &nbsp; &nbsp; &nbsp;[trn_RouteCode] [varchar]<span style="">(</span>50<span style="">)</span> <span style="">NULL,</span><br />&nbsp; &nbsp; &nbsp; &nbsp;[trn_StatusCode] [varchar]<span style="">(</span>50<span style="">)</span> <span style="">NULL,</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">)</span> <span style="">ON</span> [PRIMARY]<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">GO</span><span style=""></span><br /><br /><span style=""></span>  <span "font-size:9.5pt;font-family:consolas;="" color:blue"="">insert</span> dbo<span style="">.</span>DimTransactionsWithCCSI<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">select</span> <span style="">*</span> <span style="">from</span> dbo<span style="">.</span>DimTransactions<br /><br /><span style=""></span>  <span "font-size:9.5pt;font-family:consolas;="" color:blue"="">create</span> <span style="">clustered</span> <span style="">Columnstore</span> <span style="">index</span> dtClustColStoreIndex <span style="">ON</span> dbo<span style="">.</span>DimTransactionsWithCCSI<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">go</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">&nbsp;</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">SELECT</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp; c<span style="">.</span>cal_Year<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>i<span style="">.</span>itm_Code<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span><span style="">SUM</span><span style="">(</span>trn_NetAmt<span style="">)</span> <span style="">as</span> SumOfNetAmt<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">FROM</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp;dbo<span style="">.</span>FactTransactionsWithCCSI t<br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimCalendar c <span style="">on</span> t<span style="">.</span>trn_TransDateSK <span style="">=</span> c<span style="">.</span>cal_DateIntPK<br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimITem i <span style="">on</span> t<span style="">.</span>trn_ItemSK <span style="">=</span> i<span style="">.</span>itm_PK<br /><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">INNER</span> <span style="">JOIN</span> dbo<span style="">.</span>DimTransactions<span style="">WithCCSI</span> dt <span style="">on</span> t<span style="">.</span>trn_PK <span style="">=</span> dt<span style="">.</span>trn_PK<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">WHERE</span> t<span style="">.</span>trn_TransDateSK <span style="">Between</span> 20060101 <span style="">and</span> 20121231<br />&nbsp;&nbsp;<span style="">and</span> <span style="">dt<span style="">.</span>trn_StatusCode <span style="">&lt;&gt;</span> <span style="">'CLOSED'</span></span><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">GROUP</span> <span style="">BY</span> c<span style="">.</span>cal_Year<span style="">,</span> i<span style="">.</span>itm_Code<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">ORDER</span> BY i.itm_Code, c.cal_Year</font></font><br /><span style=""></span></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">The result is that DimTransaction now has a CCSI. &nbsp;Consequently, we now have a 'bach' <strong>Actual Execution Mode</strong> for DimTransaction vs 'Row' and our query is off and flying!</font></div>  <div><div class="wsite-image wsite-image-border-thick " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/3622804_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">Change the INNER JOINS to LEFT OUTER JOINS.</font><br /><font color="#da8044" size="2"><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">SELECT</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp; c<span style="">.</span>cal_Year<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span>i<span style="">.</span>itm_Code<br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="">,</span><span style="">SUM</span><span style="">(</span>trn_NetAmt<span style="">)</span> <span style="">as</span> SumOfNetAmt<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">FROM</span><span style=""></span><br />&nbsp; &nbsp; &nbsp; &nbsp;dbo<span style="">.</span>FactTransactionsWithCCSI t<br /><strong><span "font-size:9.5pt;font-family:consolas;="" color:gray"=""><span id="selectionBoundary_1435216558122_46190881729125977" class="rangySelectionBoundary" style="line-height: 0; display: none;">&#65279;</span>LEFT</span> <span style="">OUTER</span> </strong><span style=""><strong>JOIN</strong><span id="selectionBoundary_1435216558122_23256492614746094" class="rangySelectionBoundary" style="line-height: 0; display: none;">&#65279;</span></span> dbo<span style="">.</span>DimCalendar c <span style="">on</span> t<span style="">.</span>trn_TransDateSK <span style="">=</span> c<span style="">.</span>cal_DateIntPK<br /><strong><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">LEFT</span> <span style="">OUTER</span> <span style="">JOIN</span></strong> dbo<span style="">.</span>DimITem i <span style="">on</span> t<span style="">.</span>trn_ItemSK <span style="">=</span> i<span style="">.</span>itm_PK<br /><strong><span "font-size:9.5pt;font-family:consolas;="" color:gray"="">LEFT</span> <span style="">OUTER</span> <span style="">JOIN</span></strong> dbo<span style="">.</span>DimTransactionsWithCCSI dt <span style="">on</span> t<span style="">.</span>trn_PK <span style="">=</span> dt<span style="">.</span>trn_PK<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">WHERE</span> t<span style="">.</span>trn_TransDateSK <span style="">Between</span> 20060101 <span style="">and</span> 20121231<br />&nbsp;&nbsp;<span style="">and</span> dt<span style="">.</span>trn_StatusCode <span style="">&lt;&gt;</span> <span style="">'CLOSED'</span><br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">GROUP</span> <span style="">BY</span> c<span style="">.</span>cal_Year<span style="">,</span> i<span style="">.</span>itm_Code<br /><span "font-size:9.5pt;font-family:consolas;="" color:blue"="">ORDER</span> <span style="">BY</span> i<span style="">.</span>itm_Code<span style="">,</span> c<span style="">.</span>cal_Year<br /></font><font color="#2a2a2a"><span style=""></span></font><br /><font color="#2a2a2a"><span style=""></span></font>  <span "font-size:="" 9.5pt;font-family:consolas"="" style="color: rgb(42, 42, 42);">&nbsp;</span><font color="#2a2a2a">The result in SQL 2014 is that my LEFT OUTER joins still used &lsquo;batch&rsquo; </font><strong style="color: rgb(42, 42, 42);">Actual Execution Mode</strong><font color="#2a2a2a"> and SQL Server is even aware enough to turn the one-to-one relationship between DimTrans and FactTrans into an INNER join.</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-thick " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/5291066_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a"><strong>In summary,</strong><br /><span style=""></span><br /><span style=""></span>  1.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>With each new version of SQL Server, Columnstore is going to enhance, so do not assume that all prior guidelines and best practices remain the same.<br /><span style=""></span><br /><span style=""></span>  2.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Columnstore indexes do work and if you are running Enterprise edition, take advantage of them!<br /><span style=""></span><br /><span style=""></span>  3.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>They are intended for OLAP environments primarily.<br /><span style=""></span><br /><span style=""></span>  4.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Executing &ldquo;<span "color:#2e75b6;="" mso-themecolor:accent1;mso-themeshade:191;mso-style-textfill-fill-color:#2e75b6;="" mso-style-textfill-fill-themecolor:accent1;mso-style-textfill-fill-alpha:100.0%;="" mso-style-textfill-fill-colortransforms:lumm="75000&quot;" style="">Select * FROM MyColumnstoreIndexedTable</span>&rdquo; will not show you the benefits.&nbsp; You have to aggregate some data, group, order and filter which is the exact scenario of data warehousing queries.<br /><span style=""></span><br /><span style=""></span>  5.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>You&rsquo;ll only see significant benefits of Columnstore when working with large data volumes.<br /><span style=""></span><br /><span style=""></span>  6.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Once again, Columnstore just like SSAS, will produce the best results when working with star schema data models.<br /><span style=""></span><br /><span style=""></span>    Please remember that the purpose of this documentation is not to explain columnstore, but to help you put together a POC and prove out the capabilities of columnstore indexes.&nbsp; A blog site that I feel goes above and beyond for columnstore documentation is Niko Neugebauer and can be found here (<a href="http://www.nikoport.com/columnstore/" style="">http://www.nikoport.com/Columnstore/</a>).&nbsp; Niko&rsquo;s site has 56 tips and tricks for columnstore.&nbsp; Enjoy!</font><br /><span style=""></span></div>]]></content:encoded></item><item><title><![CDATA[t-SQL Date Calculations]]></title><link><![CDATA[https://www.delorabradish.com/dba/t-sql-date-calculations]]></link><comments><![CDATA[https://www.delorabradish.com/dba/t-sql-date-calculations#comments]]></comments><pubDate>Tue, 16 Jun 2015 22:09:49 GMT</pubDate><category><![CDATA[Date & Time]]></category><category><![CDATA[SSRS]]></category><category><![CDATA[t-SQL]]></category><guid isPermaLink="false">https://www.delorabradish.com/dba/t-sql-date-calculations</guid><description><![CDATA[I was asked today for help with defaulting SSRS report date parameters.&nbsp; In response I am sharing this snippet of t-SQL that I put together back in 2008 (yes, seven years ago!), but that still works today.&nbsp; Certainly you can do these date calculations in MDX and DAX, but how easy is this?&nbsp; Having these values return in a UDF (user defined function) also allows you to easily consume this logic&nbsp;in USPs (user stored procedures) for complex business calculations.Inserted below is [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font color="#2a2a2a">I was asked today for help with defaulting SSRS report date parameters.&nbsp; In response I am sharing this snippet of t-SQL that I put together back in 2008 (yes, seven years ago!), but that still works today.&nbsp; Certainly you can do these date calculations in MDX and DAX, but how easy is this?&nbsp; Having these values return in a UDF (user defined function) also allows you to easily consume this logic&nbsp;in USPs (user stored procedures) for complex business calculations.<br /><br />Inserted below is a correctly formatted *.sql file for download.<br /><br />  </font><font color="#2a2a2a"><font size="2"><font size="2">  <span style="color: blue; font-family: Consolas; font-size: 9.5pt;">USE</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> [YourDatabaseName]<br /></font></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">GO</span>  <br /><span></span><br /><span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">SET</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ANSI_NULLS</span> <span style="color: blue;">ON<br /></span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">GO</span><br /><span></span><br /><span></span>  <span style="color: blue; font-family: Consolas; font-size: 9.5pt;">SET</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">QUOTED_IDENTIFIER</span> <span style="color: blue;">ON<br /></span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">GO</span><br /><span></span><br /><span></span>  <span style="color: green; font-family: Consolas; font-size: 9.5pt;">/*<br /></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">Author:<span style="mso-tab-count: 3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>Delora Bradish<br /></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">Date Created:<span style="mso-tab-count: 1;"> </span>February 22, 2008<br /></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">Description:<span style="mso-tab-count: 1;">&nbsp; </span>Get date comparisons<br /></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">Where Used:<span style="mso-tab-count: 2;">&nbsp;&nbsp;&nbsp;</span>SSRS Report defaults<br /></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">Notes:<span style="mso-tab-count: 3;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />To Run:<br /><span style="color: green; font-family: Consolas; font-size: 9.5pt;"><span style="color: green; font-family: Consolas; font-size: 9.5pt;">SELECT * FROM fnGetDateRanges ('2/29/2012')</span><br /><span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">SELECT * FROM fnGetDateRanges (GetDate())</span><br /><span></span><br /><span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">SELECT top 10 * </span><br /><span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">FROM dbo.Invoice i</span><br /><span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">WHERE i.inv_DateInvoice Between (SELECT FirstDayPriorMonth3 FROM fnGetDateRanges(GetDate())) and GetDate()</span></span></span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"><br /><span></span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"><br />Revision History:<span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp; <br /></span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">*/</span><br /><span></span><br /><span></span>  <span style="color: blue; font-family: Consolas; font-size: 9.5pt;">CREATE</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font><span style="color: blue;">FUNCTION</span><font color="#000000"> [dbo]</font><span style="color: gray;">.</span><font color="#000000">[fnGetDateRanges]</font><span style="color: blue;"> </span><span style="color: gray;">(</span><font color="#000000">@i_Date<span style="mso-tab-count: 1;"> </span></font><span style="color: blue;">DateTime</span><span style="color: gray;">)<br /></span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">RETURNS</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">table<br /></span></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">AS<br /></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">RETURN</span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">(<br /></span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">SELECT</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> @i_Date </font><span style="color: blue;">as</span><font color="#000000"> iDate<br /></font></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> CurrentDate </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">DateTime</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">8</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">),</span><font color="#000000">1</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> CurrentDay </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Day</span><span style="color: gray;">(</span><font color="#000000">@i_Date</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> CurrentWeek </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DatePart</span><span style="color: gray;">(</span><span style="color: fuchsia;">Week</span><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> CurrentMonth </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><font color="#000000">@i_Date</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> CurrentYearMonth </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><font color="#000000">@i_Date</font><span style="color: gray;">))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><font color="#000000">@i_Date</font><span style="color: gray;">))),</span><font color="#000000">2</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorDay1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">DateTime</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">8</font><span style="color: gray;">),</span><font color="#000000">@i_Date </font><span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">),</span><font color="#000000">1</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorWeek </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DatePart</span><span style="color: gray;">(</span><span style="color: fuchsia;">Week</span><span style="color: gray;">,</span><font color="#000000"> @i_Date </font><span style="color: gray;">-</span><font color="#000000"> 7</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DatePart</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span><span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><span style="color: fuchsia;">day</span><span style="color: gray;">,(</span><span style="color: fuchsia;">day</span><span style="color: gray;">(</span><font color="#000000">@i_date</font><span style="color: gray;">)-</span><font color="#000000">1</font><span style="color: gray;">)*-</span><font color="#000000">1</font><span style="color: gray;">,</span><span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">1</font><span style="color: gray;">,</span><font color="#000000">@i_date</font><span style="color: gray;">)))</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font></span><br /><span></span><br /><span></span>  <span style="color: green; font-family: Consolas; font-size: 9.5pt;">--you may want to trap for leap years here<br /></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYear1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DatePart</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> @i_Date </font><span style="color: gray;">-</span><font color="#000000"> 365</font><span style="color: gray;">)</span> <br /></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYear2 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DatePart</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> @i_Date </font><span style="color: gray;">-</span><font color="#000000"> 730</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYear3 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DatePart</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> @i_Date </font><span style="color: gray;">-</span><font color="#000000"> 1086</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYear4 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DatePart</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> @i_Date </font><span style="color: gray;">-</span><font color="#000000"> 1451</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYear5 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DatePart</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> @i_Date </font><span style="color: gray;">-</span><font color="#000000"> 1816</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYear6 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DatePart</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> @i_Date </font><span style="color: gray;">-</span><font color="#000000"> 2181</font><span style="color: gray;">)</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> SameDayLastYear </font><span style="color: gray;">=</span> <span style="color: blue;">CASE</span> <span style="color: blue;">WHEN</span> <span style="color: gray;">Right(</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">8</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">),</span><font color="#000000">4</font><span style="color: gray;">)</span> <span style="color: gray;">=</span> <span style="color: red;">'0229'<br /></span></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"><span style="mso-tab-count: 6;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></font><span style="color: blue;">THEN</span><font color="#000000"> @i_Date </font><span style="color: gray;">-</span><font color="#000000"> 366<br /></font></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"><span style="mso-tab-count: 6;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></font><span style="color: blue;">ELSE</span><font color="#000000"> @i_Date </font><span style="color: gray;">-</span><font color="#000000"> 365<br /></font></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"><span style="mso-tab-count: 5;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></font><span style="color: blue;">END</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayCurrentMonth </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span><font color="#000000"> 0</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayCurrentWeek </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">ww</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">ww</font><span style="color: gray;">,</span><font color="#000000"> 0</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayCurrentYear </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 0</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayCurrentMonth </font><span style="color: gray;">=</span> <span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span> <span style="color: fuchsia;">datediff</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span><font color="#000000"> 0</font><span style="color: gray;">,</span> <span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span><font color="#000000"> 1</font><span style="color: gray;">,</span><font color="#000000"> @i_date</font><span style="color: gray;">)),</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayCurrentWeek </font><span style="color: gray;">=</span> <span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><font color="#000000">ww</font><span style="color: gray;">,</span> <span style="color: fuchsia;">datediff</span><span style="color: gray;">(</span><font color="#000000">ww</font><span style="color: gray;">,</span><font color="#000000"> 0</font><span style="color: gray;">,</span> <span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><font color="#000000">ww</font><span style="color: gray;">,</span><font color="#000000"> 1</font><span style="color: gray;">,</span><font color="#000000"> @i_date</font><span style="color: gray;">)),</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayCurrentYear </font><span style="color: gray;">=</span> <span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">datediff</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 0</font><span style="color: gray;">,</span> <span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 1</font><span style="color: gray;">,</span><font color="#000000"> @i_date</font><span style="color: gray;">)),</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">)</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">1</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">1</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth2 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">2</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">2</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth3 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">3</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">3</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth4 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">4</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">4</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth5 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">5</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">5</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth6 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">6</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">6</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth7 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">7</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">7</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth8 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">8</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">8</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth0 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">9</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">9</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth10 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">10</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">10</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth11 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">11</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">11</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth12 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">12</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">12</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorMonth13 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">Date</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">13</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))+</span> <span style="color: red;">'/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">13</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))))</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font></span><br /><span></span><br /><span></span>  <span style="color: green; font-family: Consolas; font-size: 9.5pt;">--this is the prior YYYYMM from the date passed, not the prior year's month number<br /></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">1</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth2 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">2</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth3 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">3</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth4 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">4</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth5 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">5</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth6 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">6</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth7 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">7</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth8 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">8</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth9 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">9</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth10 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">10</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth11 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">11</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth12 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">12</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorMonth13 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">13</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">))</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 2;"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">1</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">1</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth2 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">2</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">2</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth3 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">3</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">3</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth4 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">4</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">4</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth5 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">5</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">5</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth6 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">6</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">6</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth7 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">7</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">7</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth8 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">8</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">8</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth9 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">9</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">9</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth10 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">10</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">10</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth11 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">11</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">11</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth12 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">12</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">12</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYearMonth13 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">13</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,-</span><font color="#000000">13</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 2;"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><br /><span></span><br /><span></span>  <span style="color: green; font-family: Consolas; font-size: 9.5pt;">--this is the next YYYYMM from the date past, not next year's month number<br /></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYearMonth1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">1</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">1</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYearMonth2 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">2</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">2</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYearMonth3 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">3</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">3</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYearMonth4 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">4</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">4</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYearMonth5 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">5</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">5</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYearMonth6 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">int</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">4</font><span style="color: gray;">),</span><span style="color: fuchsia;">Year</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">6</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))</span> <span style="color: gray;">+</span> <span style="color: gray;">RIGHT(</span><span style="color: fuchsia;">RTrim</span><span style="color: gray;">(</span><span style="color: red;">'00'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">2</font><span style="color: gray;">),</span><span style="color: fuchsia;">Month</span><span style="color: gray;">(</span><span style="color: fuchsia;">DateAdd</span><span style="color: gray;">(</span><span style="color: fuchsia;">month</span><span style="color: gray;">,+</span><font color="#000000">6</font><span style="color: gray;">,</span><font color="#000000">@i_Date</font><span style="color: gray;">)))),</span><font color="#000000">2</font><span style="color: gray;">))</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 2;"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorWeek1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">ww</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">ww</font><span style="color: gray;">,</span><font color="#000000"> 0</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)</span> <span style="color: gray;">-</span><font color="#000000"> 7</font></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorYear1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 366</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorYear2 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 731</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorYear3 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 1096</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorYear4 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 1461</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorYear5 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 1826</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayPriorYear6 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 2191</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayPriorMonth1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">DateTime</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">8</font><span style="color: gray;">),</span><span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><font color="#000000">ms</font><span style="color: gray;">,-</span><font color="#000000">3</font><span style="color: gray;">,</span><span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span><font color="#000000">0</font><span style="color: gray;">,</span><font color="#000000">@i_date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)),</span><font color="#000000">112</font><span style="color: gray;">),</span><font color="#000000">1</font><span style="color: gray;">)</span></span><br /><span></span><br /><span></span>  <span style="color: green; font-family: Consolas; font-size: 9.5pt;">--this calculation assumes a Monday (start) to Sunday (end) week<br /></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayPriorWeek1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">DateTime</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">8</font><span style="color: gray;">),</span><span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><font color="#000000">ms</font><span style="color: gray;">,-</span><font color="#000000">3</font><span style="color: gray;">,</span><span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">ww</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">ww</font><span style="color: gray;">,</span><font color="#000000">0</font><span style="color: gray;">,</span><font color="#000000">@i_date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)),</span><font color="#000000">112</font><span style="color: gray;">),</span><font color="#000000">1</font><span style="color: gray;">)</span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastYearLastDayPriorMonth1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">DateTime</span><span style="color: gray;">,</span><span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">char</span><span style="color: gray;">(</span><font color="#000000">8</font><span style="color: gray;">),</span><span style="color: fuchsia;">dateadd</span><span style="color: gray;">(</span><font color="#000000">ms</font><span style="color: gray;">,-</span><font color="#000000">3</font><span style="color: gray;">,</span><span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">mm</font><span style="color: gray;">,</span><font color="#000000">365</font><span style="color: gray;">,</span><font color="#000000">@i_date</font><span style="color: gray;">),</span><font color="#000000"> 0</font><span style="color: gray;">)),</span><font color="#000000">112</font><span style="color: gray;">),</span><font color="#000000">1</font><span style="color: gray;">)</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 2;"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span>  <br /><span></span><br /><span></span><span style="color: green; font-family: Consolas; font-size: 9.5pt;">--you may want to trap for leap years here<br /></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayPriorYear1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 1</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayPriorYear2 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 366</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayPriorYear3 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 731</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayPriorYear4 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 1096</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayPriorYear5 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 1461</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">)<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> LastDayPriorYear6 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: fuchsia;">DATEDIFF</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span><font color="#000000"> 1826</font><span style="color: gray;">,</span><font color="#000000"> @i_Date</font><span style="color: gray;">),</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">)</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYTD1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">-</span><font color="#000000">1</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYTD2 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">-</span><font color="#000000">2</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYTD3 </font><span style="color: gray;">=</span><font color="#000000"><span style="mso-spacerun: yes;">&nbsp; </span></font><span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">-</span><font color="#000000">3</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYTD4 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">-</span><font color="#000000">4</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYTD5 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">-</span><font color="#000000">5</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> PriorYTD6 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">-</span><font color="#000000">6</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 2;"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYTD1 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">+</span><font color="#000000">1</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYTD2 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">+</span><font color="#000000">2</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYTD3 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">+</span><font color="#000000">3</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYTD4 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">+</span><font color="#000000">4</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYTD5 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">+</span><font color="#000000">5</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))<br /></span></span><span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> NextYTD6 </font><span style="color: gray;">=</span> <span style="color: fuchsia;">DATEADD</span><span style="color: gray;">(</span><font color="#000000">yy</font><span style="color: gray;">,</span> <span style="color: gray;">+</span><font color="#000000">6</font><span style="color: gray;">,</span> <span style="color: fuchsia;">Convert</span><span style="color: gray;">(</span><span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">25</font><span style="color: gray;">),</span><font color="#000000">@i_Date</font><span style="color: gray;">,</span><font color="#000000">112</font><span style="color: gray;">))</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000">&nbsp;</font></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">,</span><span style="font-family: Consolas; font-size: 9.5pt;"><font color="#000000"> FirstDayYearPriorMonth </font><span style="color: gray;">=</span> <span style="color: fuchsia;">CAST</span><span style="color: blue;"> </span><span style="color: gray;">(</span><span style="color: red;">'1/1/'</span> <span style="color: gray;">+</span> <span style="color: fuchsia;">Cast</span><span style="color: gray;">(</span><span style="color: fuchsia;">year</span><span style="color: gray;">(</span><font color="#000000">@i_Date</font><span style="color: gray;">)</span> <span style="color: gray;">-</span> <span style="color: blue;">case</span> <span style="color: fuchsia;">month</span><span style="color: gray;">(</span><font color="#000000">@i_Date</font><span style="color: gray;">)</span> <span style="color: blue;">WHEN</span><font color="#000000"> 1 </font><span style="color: blue;">THEN</span><font color="#000000"> 1 </font><span style="color: blue;">ELSE</span><font color="#000000"> 0 </font><span style="color: blue;">END</span> <span style="color: blue;">as</span> <span style="color: blue;">varchar</span><span style="color: gray;">(</span><font color="#000000">10</font><span style="color: gray;">))</span> <span style="color: blue;">as</span> <span style="color: blue;">datetime</span><span style="color: gray;">)</span></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 1;"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span></span><br /><span></span><br /><span></span>  <span style="color: gray; font-family: Consolas; font-size: 9.5pt;">)<br /><font color="#8d2424" size="4"><strong><font color="#a85f2e"><font color="#a85f2e">Example Output</font></font></strong></font></span></font></font></font><br /><span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/427633_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/9506492_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div style="margin: 10px 0 0 -10px"> <a href="https://www.delorabradish.com/uploads/5/3/4/3/53431729/dba_fngetdateranges.sql"><img src="//www.weebly.com/weebly/images/file_icons/file.png" width="36" height="36" style="float: left; position: relative; left: 0px; top: 0px; margin: 0 15px 15px 0; border: 0;" /></a><div style="float: left; text-align: left; position: relative;"><table style="font-size: 12px; font-family: tahoma; line-height: .9;"><tr><td colspan="2"><b> dba_fngetdateranges.sql</b></td></tr><tr style="display: none;"><td>File Size:  </td><td>20 kb</td></tr><tr style="display: none;"><td>File Type:  </td><td> sql</td></tr></table><a href="https://www.delorabradish.com/uploads/5/3/4/3/53431729/dba_fngetdateranges.sql" style="font-weight: bold;">Download File</a></div> </div>  <hr style="clear: both; width: 100%; visibility: hidden"></hr></div>]]></content:encoded></item><item><title><![CDATA[Installing SQL Server 2016 CTP2.0]]></title><link><![CDATA[https://www.delorabradish.com/dba/installing-sql-server-2016-ctp20]]></link><comments><![CDATA[https://www.delorabradish.com/dba/installing-sql-server-2016-ctp20#comments]]></comments><pubDate>Wed, 10 Jun 2015 13:34:28 GMT</pubDate><category><![CDATA[DBA]]></category><category><![CDATA[Installation]]></category><category><![CDATA[SQL 2016]]></category><guid isPermaLink="false">https://www.delorabradish.com/dba/installing-sql-server-2016-ctp20</guid><description><![CDATA[I will be writing more about SQL Server 2016, so this post is just cover step #1: installation. After downloading from Microsoft (http://www.microsoft.com/en-us/server-cloud/products/sql-server-2016/default.aspx), installation was typical.&nbsp; I only ran into one anomaly, the Oracle JRE.  1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If you choose to install Polybase Query Service for External Data&hellip;         &nbsp;&hellip; MS will be looking for the Java SE Runtime Environment v7 or higher.&nbs [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font color="#2a2a2a">I will be writing more about SQL Server 2016, so this post is just cover step #1: installation. After downloading from Microsoft (</font><span "font-size:11.0pt;line-height:107%;="" font-family:&quot;calibri&quot;,sans-serif;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:="" calibri;mso-fareast-theme-font:minor-latin;mso-hansi-theme-font:minor-latin;="" mso-bidi-font-family:&quot;times="" roman&quot;;mso-bidi-theme-font:minor-bidi;="" mso-ansi-language:en-us;mso-fareast-language:en-us;mso-bidi-language:ar-sa"="" style=""><a href="http://www.microsoft.com/en-us/server-cloud/products/sql-server-2016/default.aspx" style="" title="">http://www.microsoft.com/en-us/server-cloud/products/sql-server-2016/default.aspx</a></span>)<font color="#2a2a2a">, installation was typical.&nbsp; I only ran into one anomaly, the Oracle JRE.<br /><span style=""></span><br /><span style=""></span>  1.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>If you choose to install <strong>Polybase Query Service for External Data</strong>&hellip;</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/9946429.png?219" alt="Picture" style="width:219;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">&nbsp;&hellip; MS will be looking for the Java SE Runtime Environment v7 or higher.&nbsp; You can download it from here --&gt;</font>&nbsp;<a href="http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html" style="" title="">http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html</a>. &nbsp;<font color="#2a2a2a">Without the Oracle JRE installed, you will receive this failure message:</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/6368591.png?519" alt="Picture" style="width:519;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">2.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Take the defaults with these exceptions<br /></font><font color="#2a2a2a"><span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.)&nbsp; Specify a named instance<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b.)&nbsp; Be sure to add yourself as a SQL Server Admin.&nbsp; I also always add a local system account that I have created specifically for SQL Server.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c.)&nbsp; Explicitly choose your data directories<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d.)&nbsp; If you are installing on a local PC, you may wish to decrease the number of Temp DB files.</font><br /><span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/7880339.png?590" alt="Picture" style="width:590;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">&nbsp; 3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Be prepared to restart your computer.&nbsp;</font></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/2617404.png?430" alt="Picture" style="width:430;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">4.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Install a 2nd and 3rd instance for Tabular and PowerPivot SSAS instances. &nbsp;(You do not need additional database engines, DQS and SSRS for your additional SSAS instances -- you only want SSAS.)&nbsp; <br />  <font color="#000000"><br />Note: <strong style="mso-bidi-font-weight: normal;">PolyBase Query Service for External Data</strong> can only be installed on one SQL Server instance.</font></font><br /><span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/5276271.png?246" alt="Picture" style="width:246;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">5.<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>When complete, open your new SQL Server 2016 CTP2.0 Configuration Manager.</font><br /><span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/7274741_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="line-height: 1.5; background-color: initial;"><font color="#2a2a2a">Your SQL 2016 installed instances should look something like this:</font></span><br /><span></span></div>  <div><div class="wsite-image wsite-image-border-thin " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/6780093_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">That's it! &nbsp;Stay tuned for more to come of SQL Server 2016 new features.</font></div>]]></content:encoded></item><item><title><![CDATA[Working with Oracle in SQL Server]]></title><link><![CDATA[https://www.delorabradish.com/dba/working-with-oracle-in-sql-server]]></link><comments><![CDATA[https://www.delorabradish.com/dba/working-with-oracle-in-sql-server#comments]]></comments><pubDate>Mon, 25 May 2015 03:46:15 GMT</pubDate><category><![CDATA[Connecting]]></category><category><![CDATA[Oracle]]></category><category><![CDATA[SQL Developer]]></category><category><![CDATA[SSAS]]></category><category><![CDATA[SSIS]]></category><guid isPermaLink="false">https://www.delorabradish.com/dba/working-with-oracle-in-sql-server</guid><description><![CDATA[This is most assuredly a SQL Server blog site, but how often have we had to connect to an Oracle data source? &nbsp;(For me, I count my time with Oracle data sources in years.) &nbsp;If you are in SSMS, SSIS or SSAS and trying to get to Oracle, let me offer up some tips and tricks for success. &nbsp;This blog post will cover four areas last tested with Oracle 11g Release 2 Client.DownloadingInstallingConnecting from SQL to OracleUninstalling the Oracle ClientFirst, Downloading the Oracle Client. [...] ]]></description><content:encoded><![CDATA[<div class="paragraph" style="text-align:left;"><font color="#2a2a2a">This is most assuredly a SQL Server blog site, but how often have we had to connect to an Oracle data source? &nbsp;(For me, I count my time with Oracle data sources in years.) &nbsp;If you are in SSMS, SSIS or SSAS and trying to get to Oracle, let me offer up some tips and tricks for success. &nbsp;This blog post will cover four areas last tested with Oracle 11g Release 2 Client.<br /></font><ol><li><font color="#2a2a2a"><span style="line-height: 1.5; background-color: initial;">Downloading</span><br /></font></li><li><font color="#2a2a2a"><span style="line-height: 1.5; background-color: initial;">Installing</span><br /></font></li><li><font color="#2a2a2a"><span style="line-height: 1.5; background-color: initial;">Connecting from SQL to Oracle</span><br /></font></li><li><font color="#2a2a2a"><span style="line-height: 1.5; background-color: initial;">Uninstalling the Oracle Client</span></font></li></ol><strong><font color="#8d2424"><br /><br /><br />First, Downloading the Oracle Client. </font><font color="#2a2a2a">&nbsp;</font></strong><font color="#2a2a2a">You will probably need both the </font><a href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win32soft-098987.html" style="color: rgb(42, 42, 42);" title="">32-bit</a><font color="#2a2a2a"> and </font><a href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html" style="color: rgb(42, 42, 42);" title="">64-bit</a><font color="#2a2a2a"> client </font><span style="color: rgb(42, 42, 42);">from Oracle</span><font color="#2a2a2a">. &nbsp; <strong>You will use the 32-bit client when developing in SSIS. &nbsp;You will use the 64-bit client when running those packages as scheduled jobs.</strong> &nbsp;Please do not download the Oracle client from any other source except directly from Oracle, and be sure to download the client, not the database. &nbsp; The last time I needed the Oracle client, the following links worked for me:</font><br /><font color="#2a2a2a"><span style=""></span>&nbsp; &nbsp; &nbsp;32-bit --&gt;&nbsp;</font><font color="#24678d">http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win32soft-098987.html</font><br /><font color="#2a2a2a">&nbsp; &nbsp; 64-bit --&gt; </font><font color="#24678d">htt</font><span style="line-height: 1.5; background-color: initial;"><font color="#24678d">p://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-win64soft-094461.html</font></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/9056782_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/8402458_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:justify;"><font color="#2a2a2a">You may be prompted to create a free Oracle web account. &nbsp;If you download using an Internet download accelerator, it should take no more than 15 minutes.&nbsp; The result should be a &ldquo;win32_11gR2_client.zip&rdquo; and &ldquo;win64_11gR2_client.zip&rdquo; file. &nbsp;If you have TFS (team foundation server), be nice and check it in for your fellow BI team members.</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/2437916_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><strong style=""><br /></strong><br /><strong style=""><font color="#8d2424">Second, Installing the Oracle Client.</font>&nbsp;</strong><br /><font color="#2a2a2a"><span style="line-height: 1.5; background-color: initial;">Start with either the 32 or 64-bit client. &nbsp;</span><br />1.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>To understand exactly what features you are installing, use a &ldquo;Custom&rdquo; installation.<br />2.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Keep the default language of &ldquo;English" providing you are wanting an English Oracle Client</font><br /><span style=""></span></div>  <div><div style="height: 0px; overflow: hidden;"></div> 				<div id='685740183100528813-gallery' class='imageGallery' style='line-height: 0px; padding: 0; margin: 0'><div id='685740183100528813-imageContainer0' style='float:left;width:49.95%;margin:0;'><div id='685740183100528813-insideImageContainer0' style='position:relative;margin:5px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75.08%;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/8960167_orig.png' rel='lightbox[gallery685740183100528813]' onclick='if (!window.lightboxLoaded) return false' title='Use a &ldquo;Custom&rdquo; installation'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/8960167.png' class='galleryImage' _width='330' _height='236' style='position:absolute;border:0;width:100%;top:2.37%;left:0%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style='padding-left: 0px; width: 100%;margin-top:0px; margin-bottom: 0px;bottom: 2.37%; height: auto;'>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>Use a &ldquo;Custom&rdquo; installation</div>						</div>					</div>				</div></a></div></div></div></div><div id='685740183100528813-imageContainer1' style='float:left;width:49.95%;margin:0;'><div id='685740183100528813-insideImageContainer1' style='position:relative;margin:5px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75.08%;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/3118035_orig.png' rel='lightbox[gallery685740183100528813]' onclick='if (!window.lightboxLoaded) return false' title='Keep the default language of &ldquo;English"'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/3118035.png' class='galleryImage' _width='400' _height='300' style='position:absolute;border:0;width:100%;top:0.05%;left:0%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style='padding-left: 0px; width: 100%;margin-top:0px; margin-bottom: 0px;bottom: 0.05%; height: auto;'>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>Keep the default language of &ldquo;English"</div>						</div>					</div>				</div></a></div></div></div></div><span style='display: block; clear: both; height: 0px; overflow: hidden;'></span></div> 				<div style="height: 0px; overflow: hidden;"></div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a"><span style="">3.</span><span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></font><span style=""><font color="#2a2a2a">Install both Clients to &ldquo;C:\Oracle&rdquo; specifying the &ldquo;client32&rdquo; or &ldquo;client64&rdquo; subfolder as shown below.</font></span><span style=""><br /></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/6468878_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/5249889_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">4.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Install all Oracle client components EXCEPT for Oracle Net Listener and Oracle Scheduler Agent.&nbsp; .&nbsp; (If you are an experienced oracle user and know how to configure these components, feel free to install; however, they are not necessary for DW development.)</font><br /><span></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/1906326_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <span class='imgPusher' style='float:left;height:81px'></span><span style='display: table;z-index:10;width:auto;position:relative;float:left;max-width:100%;;clear:left;margin-top:20px;*margin-top:40px'><a><img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/3249855_orig.png" style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; border-width:0; max-width:100%" alt="Picture" class="galleryImageBorder wsite-image" /></a><span style="display: table-caption; caption-side: bottom; font-size: 90%; margin-top: -0px; margin-bottom: 0px; text-align: center;" class="wsite-caption"></span></span> <div class="paragraph" style="text-align:justify;display:block;"><font color="#2a2a2a">5.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Accept the default port number for MTS Recovery Services<br />6.<span style="">&nbsp; &nbsp; &nbsp;</span>If your installer is unable to check memory or disc space, you will need to &ldquo;Ignore All&rdquo; and perform this verification manually.<br /><br /><span style=""></span><br />  </font><br /><font color="#2a2a2a">Note: If you are unsure of the Oracle prerequisite conditions, click &ldquo;more details&rdquo; under each check.</font><br /><span style=""></span></div> <hr style="width:100%;clear:both;visibility:hidden;"></hr>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/31404_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">7.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Click &lt;Finish&gt;.<br /><span "font-size:11.0pt;font-family:&quot;calibri&quot;,sans-serif;="" mso-ascii-theme-font:minor-latin;mso-fareast-font-family:calibri;mso-fareast-theme-font:="" minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:&quot;times="" roman&quot;;="" mso-bidi-theme-font:minor-bidi;mso-ansi-language:en-us;mso-fareast-language:="" en-us;mso-bidi-language:ar-sa"="" style="">8. &nbsp; &nbsp; &nbsp; Perform a typical configuration as you will overwrite the tnsnames.ora file.&nbsp; This is discussed in the "Connecting" section following.</span><br /></font><span "font-size:11.0pt;font-family:&quot;calibri&quot;,sans-serif;="" mso-ascii-theme-font:minor-latin;mso-fareast-font-family:calibri;mso-fareast-theme-font:="" minor-latin;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:&quot;times="" roman&quot;;="" mso-bidi-theme-font:minor-bidi;mso-ansi-language:en-us;mso-fareast-language:="" en-us;mso-bidi-language:ar-sa"="" style=""><font color="#2a2a2a">9.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Repeat Steps #1 to #8 for your second Client installation.</font><br /><span style=""></span></span></div>  <div><div style="height: 0px; overflow: hidden;"></div> 				<div id='794857970300464264-gallery' class='imageGallery' style='line-height: 0px; padding: 0; margin: 0'><div id='794857970300464264-imageContainer0' style='float:left;width:49.95%;margin:0;'><div id='794857970300464264-insideImageContainer0' style='position:relative;margin:5px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75%;overflow:hidden;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/5758344_orig.png' rel='lightbox[gallery794857970300464264]' onclick='if (!window.lightboxLoaded) return false' title='Click <Finish>.'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/5758344.png' class='galleryImage' _width='400' _height='298' style='position:absolute;border:0;width:100.67%;top:0%;left:-0.34%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style=''>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>Click <Finish>.</div>						</div>					</div>				</div></a></div></div></div></div><div id='794857970300464264-imageContainer1' style='float:left;width:49.95%;margin:0;'><div id='794857970300464264-insideImageContainer1' style='position:relative;margin:5px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75%;overflow:hidden;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/5886070_orig.png' rel='lightbox[gallery794857970300464264]' onclick='if (!window.lightboxLoaded) return false' title='Perform a typical installation.'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/5886070.png' class='galleryImage' _width='400' _height='269' style='position:absolute;border:0;width:111.52%;top:0%;left:-5.76%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style=''>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>Perform a typical installation.</div>						</div>					</div>				</div></a></div></div></div></div><span style='display: block; clear: both; height: 0px; overflow: hidden;'></span></div> 				<div style="height: 0px; overflow: hidden;"></div></div>  <span class='imgPusher' style='float:right;height:58px'></span><span style='display: table;z-index:10;width:auto;position:relative;float:right;max-width:100%;;clear:right;margin-top:20px;*margin-top:40px'><a><img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/1521236_orig.png" style="margin-top: 5px; margin-bottom: 10px; margin-left: 0px; margin-right: 10px; none; max-width:100%" alt="Picture" class="galleryImageBorder wsite-image" /></a><span style="display: table-caption; caption-side: bottom; font-size: 90%; margin-top: -10px; margin-bottom: 10px; text-align: center;" class="wsite-caption"></span></span> <div class="paragraph" style="text-align:justify;display:block;"><font color="#2a2a2a"><strong>At this point I hear you asking, "Are we there yet?" &nbsp;Hang in there with me. &nbsp;We are on the home stretch!, but the next few steps are key critical to your Oracle Client success.</strong></font><br /><br /><br /><font color="#2a2a2a">10.</font><span style="color: rgb(42, 42, 42);">&nbsp;Verify that your</span><font color="#2a2a2a">&nbsp;</font><font color="#24678d">HKEY_LOCAL_MACHINE\SOFTWARE\Oracle</font><font color="#2a2a2a"> and </font><font color="#24678d">HKEY_CURRENT_USER\SOFTWARE\Oracle</font><font color="#2a2a2a"> system registries now have these entries:</font><br /><font color="#2a2a2a"><span style=""></span></font><br /><br /><br /><span "mso-bidi-font-family:calibri;mso-bidi-theme-font:minor-latin;color:black;="" mso-themecolor:text1"="" style="color: rgb(42, 42, 42);">11.<span style="">&nbsp; &nbsp;</span></span><span style="color: rgb(42, 42, 42);">Verify your &ldquo;Path&rdquo; environment variable has your 32 bit Oracle path BEFORE your 64 bit path.</span><br /><font color="#2a2a2a"><span "mso-bidi-font-family:="" calibri;mso-bidi-theme-font:minor-latin;color:black;mso-themecolor:text1"="">&nbsp; &nbsp;a. &nbsp;&nbsp;</span><span style="">In System Properties, click the &lt;Environment Variables&gt; button</span></font><br /><font color="#2a2a2a"><span "mso-bidi-font-family:="" calibri;mso-bidi-theme-font:minor-latin;color:black;mso-themecolor:text1"="" style="">&nbsp; &nbsp;b.<span style="">&nbsp; &nbsp;</span></span><span style="">Find &lsquo;Path&rsquo; in System Variables and click &lt;Edit&gt;.</span><br /><span style=""></span><span "mso-bidi-font-family:="" calibri;mso-bidi-theme-font:minor-latin;color:black;mso-themecolor:text1"="" style="">&nbsp; &nbsp;c.<span style="">&nbsp; &nbsp;</span></span><span style="">Copy the Variable Value out to your clipboard, paste it into a Text file, and save it in case you want to rollback.</span></font><br /></div> <hr style="width:100%;clear:both;visibility:hidden;"></hr>  <div><div style="height: 0px; overflow: hidden;"></div> 				<div id='699368657370868942-gallery' class='imageGallery' style='line-height: 0px; padding: 0; margin: 0'><div id='699368657370868942-imageContainer0' style='float:left;width:33.28%;margin:0;'><div id='699368657370868942-insideImageContainer0' style='position:relative;margin:0px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75.08%;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/511429_orig.png' rel='lightbox[gallery699368657370868942]' onclick='if (!window.lightboxLoaded) return false' title='Open your <Environment Variables>'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/511429.png' class='galleryImage' _width='281' _height='317' style='position:absolute;border:0;width:66.55%;top:0%;left:16.73%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style='padding-left: 0px; width: 66.55%;margin-top:0px; margin-bottom: 0px;left: 16.73%;'>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>Open your <Environment Variables></div>						</div>					</div>				</div></a></div></div></div></div><div id='699368657370868942-imageContainer1' style='float:left;width:33.28%;margin:0;'><div id='699368657370868942-insideImageContainer1' style='position:relative;margin:0px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75.08%;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/7490274_orig.png' rel='lightbox[gallery699368657370868942]' onclick='if (!window.lightboxLoaded) return false' title='Find &lsquo;Path&rsquo; in System Variables and click <Edit>.'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/7490274.png' class='galleryImage' _width='349' _height='152' style='position:absolute;border:0;width:100%;top:20.99%;left:0%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style='padding-left: 0px; width: 100%;margin-top:0px; margin-bottom: 0px;bottom: 20.99%; height: auto;'>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>Find &lsquo;Path&rsquo; in System Variables and click <Edit>.</div>						</div>					</div>				</div></a></div></div></div></div><div id='699368657370868942-imageContainer2' style='float:left;width:33.28%;margin:0;'><div id='699368657370868942-insideImageContainer2' style='position:relative;margin:0px;'><div class='galleryImageHolder' style='position:relative; width:100%; padding:0 0 75.08%;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/1196868_orig.png' rel='lightbox[gallery699368657370868942]' onclick='if (!window.lightboxLoaded) return false'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/1196868.png' class='galleryImage' _width='346' _height='157' style='position:absolute;border:0;width:100%;top:19.78%;left:0%' /></a></div></div></div></div><span style='display: block; clear: both; height: 0px; overflow: hidden;'></span></div> 				<div style="height: 0px; overflow: hidden;"></div></div>  <div class="paragraph" style="text-align:justify;"><font color="#2a2a2a">Your Variable Values now look something like this.&nbsp; Identify your </font><font color="#508d24">32-bit paths, highlighted here in green.</font><br /><ul><li><font color="#2a2a2a" style="font-size: small; line-height: 1.5; background-color: initial;">c:\oracle\product\11.2.0\client64\bin;</font><font color="#508d24" style="font-size: small; line-height: 1.5; background-color: initial;">c:\oracle\product\11.2.0\client32\bin;</font><font color="#2a2a2a" style="font-size: small; line-height: 1.5; background-color: initial;">C:\Program Files\RA2HP\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\ActivIdentity\ActivClient\;C:\Program Files&hellip;</font><br /></li></ul><br /><span "mso-bidi-font-family:="" calibri;mso-bidi-theme-font:minor-latin;color:black;mso-themecolor:text1"="" style="color: rgb(42, 42, 42);">&nbsp; &nbsp;d.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style=""><font color="#2a2a2a">Copy and paste your </font><font color="#508d24">32 bit path</font><font color="#2a2a2a">&nbsp;to sit BEFORE your </font><font color="#8d2424">64 bit path</font><font color="#2a2a2a">. &nbsp;</font></span><span style="color: rgb(42, 42, 42);">Your Variable Value should now look something like this.&nbsp; Make sure you don&rsquo;t leave empty spaces (!).</span><br /><ul><li><span style="line-height: 1.5; background-color: initial;"><font size="2"><font color="#508d24">c:\oracle\product\11.2.0\client32\bin;</font><font color="#8d2424">c:\oracle\product\11.2.0\client64\bin;</font><font color="#2a2a2a">C:\Program Files\RA2HP\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\ActivIdentity\ActivClient\;C:\Program Files&hellip;</font></font></span><br /></li></ul><font color="#2a2a2a"><span style=""></span><span style=""></span></font><br /><font color="#2a2a2a"><span style=""></span><span style=""></span></font>  <span "color:black;mso-themecolor:="" text1"="" style="color: rgb(42, 42, 42);">&nbsp; &nbsp;e</span><span "mso-bidi-font-family:="" calibri;mso-bidi-theme-font:minor-latin;color:black;mso-themecolor:text1"="" style="color: rgb(42, 42, 42);">.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="color: rgb(42, 42, 42);">Click &lt;OK&gt; to close your Edit System Variable window and save your changes.</span><br /><font color="#2a2a2a"><span style=""></span></font><br /><font color="#2a2a2a"><span style=""></span></font><span "mso-bidi-font-family:calibri;mso-bidi-theme-font:minor-latin;color:black;="" mso-themecolor:text1"="" style="color: rgb(42, 42, 42);">12.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><strong style="color: rgb(42, 42, 42);"><span style="">Reboot your PC </span></strong><font color="#2a2a2a">to have your &ldquo;Path&rdquo; environment variable update take effect.</font><br /><br /><br /><font color="#8d2424"><strong>Third, Connecting to Oracle</strong></font><br /><font color="#2a2a2a">You can use several tools to connect to Oracle.&nbsp; Before beginning, verify that your &ldquo;tnsnames.ora&rdquo; file (located in [YourOracleHomeDirectory]\product\11.2.0\client_1\network\admin) has the correct information as shown below.<br /></font><span style=""></span><br /><span style=""></span>                                                    #---------------------<br /># My Project Name<br />#Replace the <font color="#508d24">server name </font>below with your Oracle server name<br />#Replace the<font color="#5040ae"> IP addresses </font>with your IP address<br />#------------------------<br /><font color="#508d24">FSMISt2</font> =<br />&nbsp; (DESCRIPTION =<br />&nbsp; &nbsp; (ADDRESS_LIST =<br />&nbsp; &nbsp; &nbsp; (ADDRESS = (PROTOCOL = TCP)(HOST = <font color="#5040ae">130.175.189.36</font>)(PORT = 1523))<br />&nbsp; &nbsp; &nbsp; (ADDRESS = (PROTOCOL = TCP)(HOST = <font color="#5040ae">130.175.189.37</font>)(PORT = 1523))<br />&nbsp; &nbsp; )<br />&nbsp; &nbsp; (LOAD_BALANCE = yes)<br />&nbsp; &nbsp; (CONNECT_DATA =<br />&nbsp; &nbsp; &nbsp; (SERVER = DEDICATED)<br />&nbsp; &nbsp; &nbsp; (SERVICE_NAME = DCM2PN)<br />&nbsp; &nbsp; )<br />&nbsp; )<br /><br /><font color="#2a2a2a">1.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>From <strong style="">Visual Studio 2010 Ultimate</strong>, choose <strong>Tools </strong>--&gt;&nbsp;<strong>Connect to Database</strong> from the main menu.</font><br /><span style=""></span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;text-align:center"> <a> <img src="https://www.delorabradish.com/uploads/5/3/4/3/53431729/3318069_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">2.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;From&nbsp;<strong style="">SQL Developer</strong>, add a new connection.&nbsp; Remember that SQL Developer does not use the tnsnames.ora, but rather Java.&nbsp; If you are prompted for your jave.exe location, you will find it in [YourOracleHomeDirectory]\product\11.2.0\client_1\jdk\bin\java.exe.&nbsp; Enter your connection information as shown below.</font><br /></div>  <div><div style="height: 0px; overflow: hidden;"></div> 				<div id='618409203795661413-gallery' class='imageGallery' style='line-height: 0px; padding: 0; margin: 0'><div id='618409203795661413-imageContainer0' style='float:left;width:33.28%;margin:0;'><div id='618409203795661413-insideImageContainer0' style='position:relative;margin:0px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75.08%;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/9092878_orig.png' rel='lightbox[gallery618409203795661413]' onclick='if (!window.lightboxLoaded) return false' title='SQL Developer connection GUI'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/9092878.png' class='galleryImage' _width='400' _height='283' style='position:absolute;border:0;width:100%;top:2.88%;left:0%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style='padding-left: 0px; width: 100%;margin-top:0px; margin-bottom: 0px;bottom: 2.88%; height: auto;'>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>SQL Developer connection GUI</div>						</div>					</div>				</div></a></div></div></div></div><div id='618409203795661413-imageContainer1' style='float:left;width:33.28%;margin:0;'><div id='618409203795661413-insideImageContainer1' style='position:relative;margin:0px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75.08%;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/7034720_orig.png' rel='lightbox[gallery618409203795661413]' onclick='if (!window.lightboxLoaded) return false' title='The resulting object list in SQL Developer'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/7034720.png' class='galleryImage' _width='224' _height='481' style='position:absolute;border:0;width:34.96%;top:0%;left:32.52%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style='padding-left: 0px; width: 34.96%;margin-top:0px; margin-bottom: 0px;left: 32.52%;'>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>The resulting object list in SQL Developer</div>						</div>					</div>				</div></a></div></div></div></div><span style='display: block; clear: both; height: 0px; overflow: hidden;'></span></div> 				<div style="height: 0px; overflow: hidden;"></div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a">3.<span style="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>From an <strong style="">Analysis Services Multidimensional project</strong>, you can add a new data source, then create a Data Source View.&nbsp; <br /></font><ul><li><font color="#2a2a2a"><span style="line-height: 1.5; background-color: initial;">When create a new Data Source, make sure you select the correct Oracle driver </span><span style="line-height: 1.5; background-color: initial;">as provided by Oracle</span><span style="line-height: 1.5; background-color: initial;">, not Microsoft.</span><br /></font></li><li><span style="line-height: 1.5; background-color: initial;"><font color="#2a2a2a">When creating a Data Source View, simply select the Oracle tables from the Data Source View Wizard.&nbsp; (This may take a while depending upon your Internet connection speed and amount of available memory on your PC.)</font></span></li></ul><span style=""></span><span style=""></span></div>  <div><div style="height: 0px; overflow: hidden;"></div> 				<div id='854827224347053134-gallery' class='imageGallery' style='line-height: 0px; padding: 0; margin: 0'><div id='854827224347053134-imageContainer0' style='float:left;width:33.28%;margin:0;'><div id='854827224347053134-insideImageContainer0' style='position:relative;margin:0px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75.08%;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/1389199_orig.png' rel='lightbox[gallery854827224347053134]' onclick='if (!window.lightboxLoaded) return false' title='Make sure you select the Oracle driver as provided by Oracle or Attunity, not Microsoft'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/1389199.png' class='galleryImage' _width='400' _height='409' style='position:absolute;border:0;width:73.42%;top:0%;left:13.29%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style='padding-left: 0px; width: 73.42%;margin-top:0px; margin-bottom: 0px;left: 13.29%;'>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>Make sure you select the Oracle driver as provided by Oracle or Attunity, not Microsoft</div>						</div>					</div>				</div></a></div></div></div></div><div id='854827224347053134-imageContainer1' style='float:left;width:33.28%;margin:0;'><div id='854827224347053134-insideImageContainer1' style='position:relative;margin:0px;'><div class='galleryImageHolder galleryCaptionHover' style='position:relative; width:100%; padding:0 0 75.08%;'><div class='galleryInnerImageHolder'><a href='https://www.delorabradish.com/uploads/5/3/4/3/53431729/6189263_orig.png' rel='lightbox[gallery854827224347053134]' onclick='if (!window.lightboxLoaded) return false' title='Make sure you select the Oracle driver as supplied by Oracle or Attunity, not Microsoft.'><img src='https://www.delorabradish.com/uploads/5/3/4/3/53431729/6189263.png' class='galleryImage' _width='400' _height='390' style='position:absolute;border:0;width:77%;top:0%;left:11.5%' /><div class='galleryCaptionHolder partialImageGalleryCaption' style='padding-left: 0px; width: 77%;margin-top:0px; margin-bottom: 0px;left: 11.5%;'>					<div class='galleryCaptionHolderInnerBg'></div>					<div class='galleryCaptionHolderInner'>						<div class='galleryCaptionInnerTextHolder'>							<div class='galleryCaptionInnerText'>Make sure you select the Oracle driver as supplied by Oracle or Attunity, not Microsoft.</div>						</div>					</div>				</div></a></div></div></div></div><span style='display: block; clear: both; height: 0px; overflow: hidden;'></span></div> 				<div style="height: 0px; overflow: hidden;"></div></div>  <div class="paragraph" style="text-align:left;"><font color="#2a2a2a"><span style="">4. &nbsp; &nbsp; &nbsp;To connect to Oracle from SSMS (</span><strong style="">SQL Server Management Studio)</strong>, you can create <span "background:yellow;="" mso-highlight:yellow"="" style="">a linked server</span>. &nbsp;This is not shown here.<br /></font><span style=""></span><br /><span style=""></span><strong><font color="#8d2424"><br /><strong><br /></strong><br />Last, Uninstalling the Oracle Client.</font></strong><br /><font color="#2a2a2a">Sometimes your install doesn't go as planned -- like misnaming your Oracle installation folders. &nbsp;Read Oracle&rsquo;s instructions for uninstalling their software&nbsp;</font><a href="http://docs.oracle.com/cd/E11882_01/install.112/e24186/deinstall.htm" style="color: rgb(42, 42, 42);" title="">here</a><font color="#2a2a2a">&nbsp;--&gt; (</font><span style="color: rgb(42, 42, 42);">http://docs.oracle.com/html/B13804_02/deinstall.htm</span><br /><span style="color: rgb(42, 42, 42);"><br /></span><span style="color: rgb(42, 42, 42);">However, here are my tips and tricks when uninstalling Oracle: &nbsp;</span><br /><ol style=""><li style=""><font color="#2a2a2a">You will need to use an Oracle utility to uninstall.&nbsp; In 10g and earlier you could use the Oracle Universal Installer.&nbsp; If you are trying to connect an 11g install, you will need to use the uninstaller located at C:\{OracleHome}\product\11.2.0\client_1\deinstall\deinstall.bat.&nbsp; (Be sure to run the bat file &lsquo;As Administrator&rsquo; even if you are an Admin on the server.)</font></li><li style=""><font color="#2a2a2a">After uninstalling, reboot your PC<br /></font></li><li style=""><font color="#2a2a2a">Upon start up,&nbsp;<strong style="">rename the Oracle directory</strong>&nbsp;where the Oracle software has been uninstalled but&nbsp;<em style="">the directory and certain files remain</em>.<br /></font></li><li style=""><font color="#2a2a2a"><strong style="">Delete the Oracle folder from your system registry</strong>&nbsp;(HKEY_LOCAL_MACHINE\SOFTWARE\Oracle and HKEY_CURRENT_USER\SOFTWARE\Oracle).&nbsp; You will have quite a few Oracle entries remaining in HKEY_CLASSES_ROOT.<br /></font></li><li style=""><font color="#2a2a2a">Reinstall Oracle.<br /></font></li><li style=""><font color="#2a2a2a">Test your Oracle connection<br /></font></li><li style=""><font color="#2a2a2a">Delete the old Oracle installation folder that you renamed in Step #3 above.</font></li></ol></div>]]></content:encoded></item></channel></rss>