<?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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Sam Vanga&#039;s</title>
	<atom:link href="http://svangasql.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://svangasql.wordpress.com</link>
	<description>SQL Server, T-SQL, BI and more...</description>
	<lastBuildDate>Tue, 21 Feb 2012 12:05:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='svangasql.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/d4ba0588370d321eada90c94e8d30479?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Sam Vanga&#039;s</title>
		<link>http://svangasql.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://svangasql.wordpress.com/osd.xml" title="Sam Vanga&#039;s" />
	<atom:link rel='hub' href='http://svangasql.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Creating Your First SSAS 2012 Tabular Project</title>
		<link>http://svangasql.wordpress.com/2012/02/21/creating-your-first-ssas-2012-tabular-project/</link>
		<comments>http://svangasql.wordpress.com/2012/02/21/creating-your-first-ssas-2012-tabular-project/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 12:00:00 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[Analysis Services]]></category>
		<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[SSAS Tabular]]></category>
		<category><![CDATA[bi]]></category>
		<category><![CDATA[BISM]]></category>
		<category><![CDATA[ssas]]></category>
		<category><![CDATA[sssa 2012]]></category>
		<category><![CDATA[Tabular]]></category>

		<guid isPermaLink="false">https://svangasql.wordpress.com/?p=1248</guid>
		<description><![CDATA[No matter how simple it is, new things come with some confusion; at least until you get used to it. Analysis Services 2012 Tabular is no different. This post will look at steps to create your first Tabular project. Let’s start with firing up SQL Server Data Tools located under Microsoft SQL Server 2012 RC0. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=1248&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>No matter how simple it is, new things come with some confusion; at least until you get used to it. Analysis Services 2012 Tabular is no different. This post will look at steps to create your first Tabular project.</p>
<p>Let’s start with firing up SQL Server Data Tools located under Microsoft SQL Server 2012 RC0. I’ve selected to create a new project.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/sql-server-2012-ssas-tabular-project.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;margin:0 5px;" title="SQL Server 2012 SSAS Tabular Project" src="http://svangasql.files.wordpress.com/2012/02/sql-server-2012-ssas-tabular-project_thumb.png?w=390&#038;h=225" alt="SQL Server 2012 SSAS Tabular Project" width="390" height="225" border="0" /></a></p>
<p>In the above image, I’ve selected Analysis Services Tabular Project.</p>
<p>You might see a error message similar to the one below. This happens when the server instance specified in the Workspace Server property doesn’t have an analysis services running in tabular mode. For instance, in this example the name of my instance is localhost\SQL110, but I purposefully changed it to an incorrect name to show this error.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/ssas-tabular-workspace-database-server-error.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 5px;" title="SSAS Tabular Workspace database server error" src="http://svangasql.files.wordpress.com/2012/02/ssas-tabular-workspace-database-server-error_thumb.png?w=310&#038;h=115" alt="SSAS Tabular Workspace database server error" width="310" height="115" border="0" /></a></p>
<p>To fix this, I’ve changed Workspace Server to the correct one from the properties of model.bim</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 5px;" title="image" src="http://svangasql.files.wordpress.com/2012/02/image_thumb.png?w=240&#038;h=185" alt="image" width="240" height="185" border="0" /></a></p>
<h2>Importing Data</h2>
<p>The Model option located on the top allows you to create model files. You’ll begin with importing data from a source.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/image1.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 5px;" title="image" src="http://svangasql.files.wordpress.com/2012/02/image_thumb1.png?w=217&#038;h=204" alt="image" width="217" height="204" border="0" /></a></p>
<p>The next screen lets you select a type of data source. I’ve selected Microsoft SQL Server. In the next screen, you choose a server name and database name as the source.</p>
<p>You’ll provide impersonation information in the next screen. This is important because, analysis services uses this account to connect to the data source. So, make sure that this account has required permissions on both the server instances: data source and analysis services.</p>
<p>Next screen asks how you want to import the data. You can either choose from a list of tables or view, or specify a query to retrieve the data. I’ve opted to select from a list.</p>
<p>From the list of tables and views in the below image, I’ve selected FactInternetSales, DimProduct, DimProductSubCategory, DimProductCategory, DimCustomer, and DimGeography.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/image2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 5px;" title="image" src="http://svangasql.files.wordpress.com/2012/02/image_thumb2.png?w=249&#038;h=226" alt="image" width="249" height="226" border="0" /></a></p>
<p>Clicking finish will complete by the data import and the next screen displays a status of the tables and views that were imported.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/image3.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 5px;" title="image" src="http://svangasql.files.wordpress.com/2012/02/image_thumb3.png?w=265&#038;h=230" alt="image" width="265" height="230" border="0" /></a></p>
<p>Toggle to the diagram view to see the tables and relationships among the objects in the model. In the below image, you’ll notice the wizard identifies the relationships in the data source.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/image4.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 5px;" title="image" src="http://svangasql.files.wordpress.com/2012/02/image_thumb4.png?w=395&#038;h=194" alt="image" width="395" height="194" border="0" /></a></p>
<p>Toggle to the grid view to see the data that was imported from data source to the model. This interface looks similar or Excel workbooks with one tab for each table in the data source.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/image5.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 5px;" title="image" src="http://svangasql.files.wordpress.com/2012/02/image_thumb5.png?w=398&#038;h=153" alt="image" width="398" height="153" border="0" /></a></p>
<h2>Create Measures</h2>
<p>The first thing you should do after importing data is to create measures. I’ll select Sales Amount and choose Sum from the measure drop down in the following image.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/image6.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 5px;" title="image" src="http://svangasql.files.wordpress.com/2012/02/image_thumb6.png?w=490&#038;h=265" alt="image" width="490" height="265" border="0" /></a></p>
<p>I’ve repeated the same steps for Tax Amount, to create another measure.</p>
<h2>Deploy To Target Server</h2>
<p>Before deploying to the server, take a few seconds to verify the target server properties. Target Analysis Services must be running in tabular mode.</p>
<p>In the below image, I’ve selected to deploy the model.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/image7.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;margin:0 5px;" title="image" src="http://svangasql.files.wordpress.com/2012/02/image_thumb7.png?w=325&#038;h=155" alt="image" width="325" height="155" border="0" /></a></p>
<h2>Browse Your First Tabular Model</h2>
<p>I selected Analyze in Excel option located on the top. An excel pivot table with a connection to the model you just deployed allows you to analyze data in Excel.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/image8.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://svangasql.files.wordpress.com/2012/02/image_thumb8.png?w=336&#038;h=140" alt="image" width="336" height="140" border="0" /></a></p>
<h2>Conclusion</h2>
<p>Well, Well, Well. I know this has been a lengthy post. So I’ll let you go with no further ado, but please use the comments below should you have any questions or comments.</p>
<p>~<a href="http://Twitter.com/SamuelVanga">Sam</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/1248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/1248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/1248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/1248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/1248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/1248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/1248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/1248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/1248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/1248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/1248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/1248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/1248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/1248/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=1248&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2012/02/21/creating-your-first-ssas-2012-tabular-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/sql-server-2012-ssas-tabular-project_thumb.png" medium="image">
			<media:title type="html">SQL Server 2012 SSAS Tabular Project</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/ssas-tabular-workspace-database-server-error_thumb.png" medium="image">
			<media:title type="html">SSAS Tabular Workspace database server error</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/image_thumb8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Be careful with two digit years</title>
		<link>http://svangasql.wordpress.com/2012/02/14/two-digit-years-sql-server/</link>
		<comments>http://svangasql.wordpress.com/2012/02/14/two-digit-years-sql-server/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 13:10:17 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[t-sql]]></category>
		<category><![CDATA[funny]]></category>
		<category><![CDATA[two year digit]]></category>
		<category><![CDATA[sql servr]]></category>

		<guid isPermaLink="false">http://svangasql.wordpress.com/?p=1069</guid>
		<description><![CDATA[I recently had a scary conversation with a user, which can be broken down to: User: Why would the data have customers with a birth date of MM/DD/2020? Me: What are you talking about? Lemme take a look. Me again, this time with a changed voice: Umm, Umm, i plead guilty with an explanation your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=1069&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently had a scary conversation with a user, which can be broken down to:</p>
<p><strong>User</strong>: Why would the data have customers with a birth date of MM/DD/2020?</p>
<p><strong>Me</strong>: What are you talking about? Lemme take a look.</p>
<p><strong>Me again</strong>, this time with a changed voice: Umm, Umm, i plead guilty with an explanation your honor!</p>
<p><strong>User</strong>: Let&#8217;s hear your explanation son.</p>
<p><strong>Me</strong>: We receive a raw file with customer data. Date of birth is a field in that file, and it is supposed to contain data in &#8216;DD-Month-YYYY&#8217; format. But, apparently, one fine day the file contained two digits for year instead of four. My import process decided that the two digit year 20 is 2020 and not 1920.</p>
<p><strong>User</strong>: Okay, I&#8217;ll let you go this time, but fix it. Won&#8217;t you?</p>
<p>&lt;end of story&gt;.</p>
<p>Turns out, SQL Server automatically uses current century for two digit years less than 50, and previous century for years greater than or equal to 50.</p>
<p><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:red;">'01-January-49' </span><span style="color:blue;">AS DATETIME</span><span style="color:gray;">) </span><span style="color:black;">[&lt;50]</span></code></p>
<p>Result:</p>
<p>&lt;50<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
2049-01-01 00:00:00.000</p>
<p>(1 row(s) affected)</p>
<p><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:magenta;">CAST</span><span style="color:gray;">(</span><span style="color:red;">'01-January-50' </span><span style="color:blue;">AS DATETIME</span><span style="color:gray;">) </span><span style="color:black;">[&gt;50]</span></code></p>
<p>Result:</p>
<p>&lt;50<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
1950-01-01 00:00:00.000</p>
<p>(1 row(s) affected)</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms189577.aspx" target="_blank">Here</a> is the books online explanation for the two digit year cutoff. Benjamin Nevarez (<a href="https://twitter.com/#!/BenjaminNevarez" target="_blank">t</a>|<a href="http://www.benjaminnevarez.com/" target="_blank">b</a>) pointed me to this link when i asked for help on twitter using the #sqlhelp hashtag. Thanks Benjamin.</p>
<p>Cheers!</p>
<p><a href="https://twitter.com/#!/SamuelVanga" target="_blank">@SamuelVanga</a>.</p>
<p>You will also like <a title="Management Studio Split Tabs" href="http://svangasql.wordpress.com/2012/01/03/management-studio-split-tabs/" target="_blank">If i learn something, sorry, but you have to read it</a>!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/1069/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/1069/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/1069/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=1069&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2012/02/14/two-digit-years-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>
	</item>
		<item>
		<title>LAST_VALUE() Analytic Function–SQL Server 2012</title>
		<link>http://svangasql.wordpress.com/2012/02/07/last_value-analytic-function-sql-server-2012-2/</link>
		<comments>http://svangasql.wordpress.com/2012/02/07/last_value-analytic-function-sql-server-2012-2/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 12:00:34 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[Analytic Functions]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[analytic functions]]></category>
		<category><![CDATA[last_value]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://svangasql.wordpress.com/?p=1169</guid>
		<description><![CDATA[Earlier, i discussed FIRST_VALUE() function. FIRST_VALUE() returns the first value from an ordered set of records. Similarly LAST_VALUE() returns the last value for an ordered result set, but you are in for a bit of a surprise if you aren&#8217;t familiar with the enhancements to the SQL windows functions. I&#8217;ll use the same example data i [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=1169&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Earlier, i discussed <a title="FIRST_VALUE() Analytic Function–SQL Server 2012" href="http://svangasql.wordpress.com/2012/01/10/first_value-analytic-function-sql-server-2012/">FIRST_VALUE</a>() function. FIRST_VALUE() returns the first value from an ordered set of records. Similarly LAST_VALUE() returns the last value for an ordered result set, but you are in for a bit of a surprise if you aren&#8217;t familiar with the enhancements to the SQL windows functions.</p>
<p>I&#8217;ll use the same example data i used earlier.</p>
<p><code style="font-size:12px;"><span style="color:blue;">CREATE TABLE </span><span style="color:black;">Customers<br />
</span><span style="color:gray;">(</span><span style="color:black;">CustId </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:black;">OrderDate DATE</span><span style="color:gray;">, </span><span style="color:black;">OrderAmount MONEY</span><span style="color:gray;">) ;</span></code></p>
<p><span style="color:blue;">INSERT </span><span style="color:black;">Customers </span><span style="color:blue;">VALUES<br />
</span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-12-03&#8242;</span><span style="color:gray;">, </span><span style="color:black;">12500</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-10-07&#8242;</span><span style="color:gray;">, </span><span style="color:black;">15000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-09-12&#8242;</span><span style="color:gray;">, </span><span style="color:black;">16000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">2</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-07-11&#8242;</span><span style="color:gray;">, </span><span style="color:black;">900</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">2</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-09-13&#8242;</span><span style="color:gray;">, </span><span style="color:black;">18000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">2</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-11-03&#8242;</span><span style="color:gray;">, </span><span style="color:black;">7000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">3</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-01-29&#8242;</span><span style="color:gray;">, </span><span style="color:black;">19000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">3</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-04-19&#8242;</span><span style="color:gray;">, </span><span style="color:black;">1000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">3</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-07-09&#8242;</span><span style="color:gray;">, </span><span style="color:black;">12000</span><span style="color:gray;">) ;</span></p>
<p>We wrote a query using FIRST_VALUE() to calculate the date of first purchase for each customer.</p>
<p><code style="font-size:12px;"><span style="color:blue;">SELECT<br />
</span><span style="color:black;">c.CustId</span><span style="color:gray;">, </span><span style="color:black;">c.OrderDate</span><span style="color:gray;">, </span><span style="color:black;">c.OrderAmount<br />
</span><span style="color:gray;">, </span><span style="color:black;">FIRST_VALUE</span><span style="color:gray;">(</span><span style="color:black;">OrderDate</span><span style="color:gray;">) </span><span style="color:blue;">OVER</span><span style="color:gray;">(</span><span style="color:black;">PARTITION </span><span style="color:blue;">BY </span><span style="color:black;">CustId </span><span style="color:blue;">ORDER BY </span><span style="color:black;">OrderDate</span><span style="color:gray;">) </span><span style="color:black;">CustomerSince<br />
</span><span style="color:blue;">FROM<br />
</span><span style="color:black;">Customers c</span></code></p>
<div>
<p>Now, let&#8217;s say we want to know the recent purchase date for each customer. Similar to FIRST_VALUE(), there is a LAST_VALUE() function. LAST_VALUE() allows you to return the last value from an ordered result set.</p>
<p>I&#8217;ll follow my killer instincts and replace FIRST_VALUE() with LAST_VALUE() in the above query. It should work. Right?</p>
<p><code style="font-size:12px;"><span style="color:blue;">SELECT<br />
</span><span style="color:black;">c.CustId</span><span style="color:gray;">, </span><span style="color:black;">c.OrderDate</span><span style="color:gray;">, </span><span style="color:black;">c.OrderAmount<br />
</span><span style="color:gray;">, </span><span style="color:black;">LAST_VALUE</span><span style="color:gray;">(</span><span style="color:black;">OrderDate</span><span style="color:gray;">) </span><span style="color:blue;">OVER</span><span style="color:gray;">(</span><span style="color:black;">PARTITION </span><span style="color:blue;">BY </span><span style="color:black;">CustId </span><span style="color:blue;">ORDER BY </span><span style="color:black;">OrderDate</span><span style="color:gray;">) </span><span style="color:black;">CustomerSince<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">Customers C</span></code></p>
<p>Result Set:</p>
<p><a href="http://svangasql.files.wordpress.com/2012/02/last_value-analytic-function-repeating-same-row.png"><img class="size-medium wp-image-1183 alignnone" style="border-color:initial;border-style:initial;" title="LAST_VALUE() Analytic Function repeating same row" src="http://svangasql.files.wordpress.com/2012/02/last_value-analytic-function-repeating-same-row.png?w=300&#038;h=156" alt="" width="300" height="156" /></a></p>
<p>&#8230; but, oops, this is not the result i was expecting.</p>
<p>There are two points to note here. Window and Frame.</p>
<p>A window is a set of records that are defined by the OVER() clause. Because of the PARTITION BY Custid, you can safely think records for each Custid form a window in this example.</p>
<p>A Frame is a range of rows within a window; a subset of a window in other words, defined by the ROWS clause. A range has boundaries &#8211; a begin position and an end position.</p>
<p>Look back at the query using LAST_VALUE(). You&#8217;ll notice there wasn&#8217;t a ROWS clause. We haven&#8217;t defined a frame. In this case SQL Server uses the default frame which is, between the first row without any boundaries (first row of the window partition) and the current row. Last value from this default frame will always be the current row.</p>
<p>Correct usage of the function should instead be:</p>
<p><code style="font-size:12px;"><span style="color:blue;">SELECT<br />
</span><span style="color:black;">c.CustId</span><span style="color:gray;">, </span><span style="color:black;">c.OrderDate</span><span style="color:gray;">, </span><span style="color:black;">c.OrderAmount<br />
</span><span style="color:gray;">, </span><span style="color:black;">LAST_VALUE</span><span style="color:gray;">(</span><span style="color:black;">OrderDate</span><span style="color:gray;">) </span><span style="color:blue;">OVER</span><span style="color:gray;">(</span><span style="color:black;">PARTITION </span><span style="color:blue;">BY </span><span style="color:black;">CustId </span><span style="color:blue;">ORDER BY </span><span style="color:black;">OrderDate ROWS </span><span style="color:gray;">BETWEEN  </span><span style="color:blue;">CURRENT </span><span style="color:black;">ROW </span><span style="color:gray;">AND </span><span style="color:black;">UNBOUNDED FOLLOWING</span><span style="color:gray;">)<br />
</span><span style="color:blue;">FROM </span><span style="color:black;">Customers C</span></code></p>
<p>Given all this, FIRST_VALUE() is providing expected results even with the default frame because the first row in the default frame is the first row of the window partition.</p>
<p>Here is an interesting article from Jeremiah Peschka (<a href="http://www.brentozar.com/archive/author/jeremiah-peschka/" target="_blank">blog</a>) for further reading: <a href="http://www.brentozar.com/archive/2011/07/leaving-windows-open/" target="_blank">Leaving the Windows Open</a>.</p>
<p>~<a title="About" href="http://svangasql.wordpress.com/about/" target="_blank">Sam</a></p>
<p>Follow Sam on Twitter - <em><a href="https://twitter.com/#!/SamuelVanga" target="_blank">@SamuelVanga</a></em></p>
</div>
<p><code style="font-size:12px;"><span style="color:black;"><br />
</span></code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/1169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/1169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/1169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/1169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/1169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/1169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/1169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/1169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/1169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/1169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/1169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/1169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/1169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/1169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=1169&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2012/02/07/last_value-analytic-function-sql-server-2012-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/02/last_value-analytic-function-repeating-same-row.png?w=300" medium="image">
			<media:title type="html">LAST_VALUE() Analytic Function repeating same row</media:title>
		</media:content>
	</item>
		<item>
		<title>Data Labels, Axis Interval, Rotate Label Text: SSRS Nugget</title>
		<link>http://svangasql.wordpress.com/2012/01/31/data-labels-axis-interval-rotate-label-text-ssrs-nugget/</link>
		<comments>http://svangasql.wordpress.com/2012/01/31/data-labels-axis-interval-rotate-label-text-ssrs-nugget/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 12:30:00 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[Reporting Services]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[axis interval]]></category>
		<category><![CDATA[rotate labels]]></category>
		<category><![CDATA[show data labels]]></category>
		<category><![CDATA[ssrs]]></category>
		<category><![CDATA[ssrs chart]]></category>

		<guid isPermaLink="false">https://svangasql.wordpress.com/?p=969</guid>
		<description><![CDATA[Charts present summary data in a visually appealing format. Following is a chart for sales over month: I frequently use a few options along with charts to get most out of them. Show data labels: It’ll be easier for the users to quickly read, if the chart shows the actual numbers along with bars. Steps: From [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=969&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://technet.microsoft.com/en-us/library/dd239351.aspx" target="_blank">Charts</a> present summary data in a visually appealing format. Following is a chart for sales over month:</p>
<div class="wp-caption aligncenter" style="width: 510px"><br />
<img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image9.png?w=500&#038;h=209" alt="image" width="500" height="209" border="0" /><p class="wp-caption-text">Before</p></div>
<p>I frequently use a few options along with charts to get most out of them.</p>
<h3><strong>Show data labels</strong>:</h3>
<p>It’ll be easier for the users to quickly read, if the chart shows the actual numbers along with bars. Steps: From the chart data pane, click data value, and choose Show Data Labels.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image10.png?w=328&#038;h=287" alt="image" width="328" height="287" border="0" /></p>
<h3><strong>Display all categories on horizontal axis</strong>:</h3>
<p>Notice in the above chart, all the categories (Months in our example) are not displayed. By default, auto fit property determines the interval of horizontal axis labels. Changing the interval to 1 will force the axis to display all categories. Steps are depicted in the below screen prints.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image11.png?w=396&#038;h=151" alt="image" width="396" height="151" border="0" /></p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image12.png?w=400&#038;h=354" alt="image" width="400" height="354" border="0" /></p>
<h3><strong>Rotate Labels</strong>:</h3>
<p>Sometimes you may notice the labels are rotated automatically to better fit them, other times labels overlap with each other. Labels can be forced to rotate by disabling auto-fit and changing the label rotation angle to 90 degrees.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image13.png?w=402&#038;h=336" alt="image" width="402" height="336" border="0" /></p>
<div class="wp-caption aligncenter" style="width: 510px"><br />
<img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image14.png?w=500&#038;h=256" alt="image" width="500" height="256" border="0" /><p class="wp-caption-text">After</p></div>
<h3><strong>Summary</strong>:</h3>
<p>In this post, I’ve looked at simple properties that can extend chart’s functionality: Showing data labels, configuring axis interval, and rotating axis labels.</p>
<p><a href="http://svangasql.wordpress.com/" target="_blank">~Sam</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/969/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/969/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/969/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=969&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2012/01/31/data-labels-axis-interval-rotate-label-text-ssrs-nugget/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image10.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image11.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image12.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image13.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image14.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Read contents of a file to variable &#8211; SSIS</title>
		<link>http://svangasql.wordpress.com/2012/01/24/how-to-read-a-flat-file-to-variable-ssis-script-task/</link>
		<comments>http://svangasql.wordpress.com/2012/01/24/how-to-read-a-flat-file-to-variable-ssis-script-task/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 12:00:16 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[SSIS]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[script task]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://svangasql.wordpress.com/?p=339</guid>
		<description><![CDATA[Sometimes you will find the need to import a file to a variable using SSIS. In this post, I&#8217;ll use Script Task to read contents of a flat file into a variable. I&#8217;ve created a file called &#8216;myfile.txt&#8217; with some random text. I&#8217;ll configure script task to read this file into a SSIS variable. First create a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=339&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes you will find the need to import a file to a variable using SSIS. In this post, I&#8217;ll use Script Task to read contents of a flat file into a variable.</p>
<p>I&#8217;ve created a file called &#8216;myfile.txt&#8217; with some random text. I&#8217;ll configure script task to read this file into a SSIS variable.</p>
<ul>
<li>First create a variable with string data type. I&#8217;ll call mine vText.</li>
<li>Drag a script task onto the control flow. As you would imagine double clicking the script task will open the editor.</li>
<li>Specify the variable you just created as a ReadWriteVariable.</li>
<li>Click edit script and use code similar to what you see below:</li>
</ul>
<p><code style="font-size:12px;"><span style="color:green;">'initialize StreamReader class for text file<br />
</span><span style="color:blue;">Dim </span><span style="color:black;">streamReader </span><span style="color:blue;">As New </span><span style="color:black;">StreamReader</span><span style="color:gray;">(</span><span style="color:darkred;">"D:\Documents\myfile.txt"</span><span style="color:gray;">)</span><span style="color:gray;"><br />
</span><span style="color:green;">' Read the StreamReader To End and assign to local variable<br />
</span><span style="color:blue;">Dim </span><span style="color:black;">StreamText </span><span style="color:blue;">As String = </span><span style="color:black;">streamReader.ReadToEnd</span><span style="color:gray;">()<br />
</span><span style="color:green;">' assign SSIS variable with value of StreamText local variable.<br />
</span><span style="color:black;">Me.Dts.Variables</span><span style="color:gray;">(</span><span style="color:darkred;">"vText"</span><span style="color:gray;">)</span><span style="color:black;">.Value </span><span style="color:blue;">= </span><span style="color:black;">StreamText</span></code></p>
<p>To test, I&#8217;ll add another script task. This task will show a message box with the contents of our variable. Following is the script i use for message box:</p>
<p><code style="font-size:12px;"><span style="color:black;">MsgBox</span><span style="color:gray;">(</span><span style="color:black;">Dts.Variables</span><span style="color:gray;">(</span><span style="color:darkred;">"vText"</span><span style="color:gray;">)</span><span style="color:black;">.Value.ToString</span><span style="color:gray;">)</span></code></p>
<p>As you can see I&#8217;m reading the file from a static location on my D drive. Most people, however, will use variables or expressions to read from any locations dynamically.</p>
<p><em><a title="Samuel on Twitter" href="https://twitter.com/#!/SamuelVanga">@SamuelVanga</a></em>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/339/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/339/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/339/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=339&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2012/01/24/how-to-read-a-flat-file-to-variable-ssis-script-task/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>
	</item>
		<item>
		<title>#meme15 &#8211; Use. Twitter. Why?</title>
		<link>http://svangasql.wordpress.com/2012/01/16/why-should-you-start-using-twitter/</link>
		<comments>http://svangasql.wordpress.com/2012/01/16/why-should-you-start-using-twitter/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 12:30:00 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[meme15]]></category>
		<category><![CDATA[#meme15]]></category>
		<category><![CDATA[social media]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">https://svangasql.wordpress.com/?p=1026</guid>
		<description><![CDATA[Should an average Jane or Joe professional use twitter? Yes. Why? Because, I’m using it. Not enough reasons? &#60;grumpy face&#62; I knew you wouldn’t buy this. Okay, allow me to present why you should: Advertise. You might be thinking, “I’m neither an author nor do i have any business to advertise”. True, but do you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=1026&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:left;" align="center"><em>Should an average Jane or Joe professional use twitter?<a href="http://www.jasonstrate.com/2012/01/january-meme15-assignment/" target="_blank"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:right;padding-top:0;border:0;" title="meme15new" src="http://svangasql.files.wordpress.com/2012/01/meme15new1.png?w=124&#038;h=129" alt="meme15new" width="124" height="129" align="right" border="0" /></a></em></p>
<p style="text-align:left;" align="center">Yes.</p>
<p><em>Why</em>?</p>
<p>Because, I’m using it.</p>
<p><em>Not enough reasons</em>? &lt;grumpy face&gt; I knew you wouldn’t buy this.</p>
<p>Okay, allow me to present why you should:</p>
<h3><strong>Advertise</strong>.</h3>
<p>You might be thinking, “I’m neither an author nor do i have any business to advertise”. True, but do you have a blog? Are you working on any interesting project? Are you a character? If the answer to any of these questions is yes, then yes, you’ve something to advertise.</p>
<h3><strong>Follow your interests</strong>.</h3>
<p>Twitter makes it easy to follow your interests: people, events, or anything else, so you can stay up to date of what’s happening around your interests. I’ll use me as an example: I follow a (very) few people. No, I don&#8217;t follow celebs like <a href="http://twitter.com/kimkardashian" target="_blank">@KimKardashian</a> or <a href="http://twitter.com/justinbieber" target="_blank">@justinbieber</a> – I don’t care what they do – oh, sorry, my interests don’t match theirs. Instead, I follow people from whom I learn new things, people whom I find interesting, people those inspire me. If any of those people write a new article, I want to know about it. With Twitter, i can know the news from all the people at a single place.</p>
<h3><strong>Interact</strong>.</h3>
<p>Example. Mine. Again.</p>
<p>I follow Marco Russo (<a href="http://sqlblog.com/blogs/marco_russo/default.aspx" target="_blank">blog</a>|<a href="http://twitter.com/marcorus" target="_blank">@Marcorus</a>). Marco tweeted that he was doing a session on Vertipaq vs OLAP.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/01/image.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://svangasql.files.wordpress.com/2012/01/image_thumb.png?w=363&#038;h=132" alt="image" width="363" height="132" border="0" /></a></p>
<p>I was excited about it and wanted to attend, but couldn&#8217;t. I tweeted this.</p>
<p><a href="http://svangasql.files.wordpress.com/2012/01/image1.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://svangasql.files.wordpress.com/2012/01/image_thumb1.png?w=361&#038;h=103" alt="image" width="361" height="103" border="0" /></a></p>
<p>A tweet appeared magically from Marco saying, hey Sam &#8211; you are awesome, this session has been recorded for you. Ha, I&#8217;m dreaming here. But you can see his tweet below:</p>
<p><a href="http://svangasql.files.wordpress.com/2012/01/image2.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border:0;" title="image" src="http://svangasql.files.wordpress.com/2012/01/image_thumb2.png?w=362&#038;h=111" alt="image" width="362" height="111" border="0" /></a></p>
<p>This shows how Twitter makes it easy for a novice like me to interact with a master like Marco.</p>
<h3><strong>Wrap it&#8230;</strong></h3>
<p>I’m sure there are other ways to achieve these – but don’t you want to pick the horse that wins the race?</p>
<p>There are more reasons, oh yes, more. Need’em? Sure. Fantastrateic bloggers are giving more reasons <a href="http://www.jasonstrate.com/2012/01/january-meme15-assignment/" target="_blank">here</a>, while participating in this month’s #meme15, created by Jason Strate (<a href="http://twitter.com/#!/stratesql">t</a>).</p>
<p>When you are ready to start using Twitter, read this <a href="http://www.brentozar.com/twitter/book/" target="_blank">free simple twitter e-book</a> by Brent Ozar (<a href="http://twitter.com/BrentO" target="_blank">@BrentO</a>). You will thank me later.</p>
<p>See ya on the Twitter world…</p>
<p><em><a href="http://twitter.com/SamuelVanga" target="_blank">@SamuelVanga</a></em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/1026/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/1026/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/1026/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=1026&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2012/01/16/why-should-you-start-using-twitter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/01/meme15new1.png" medium="image">
			<media:title type="html">meme15new</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/01/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/01/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2012/01/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>FIRST_VALUE() Analytic Function&#8211;SQL Server 2012</title>
		<link>http://svangasql.wordpress.com/2012/01/10/first_value-analytic-function-sql-server-2012/</link>
		<comments>http://svangasql.wordpress.com/2012/01/10/first_value-analytic-function-sql-server-2012/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 14:30:00 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[Analytic Functions]]></category>
		<category><![CDATA[T-SQL]]></category>
		<category><![CDATA[analytic functions]]></category>
		<category><![CDATA[first_value()]]></category>
		<category><![CDATA[sql server 2012]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">https://svangasql.wordpress.com/?p=833</guid>
		<description><![CDATA[Given a customer table: CREATE TABLE Customers (CustId INT, OrderDate DATE, OrderAmount MONEY) ; INSERT Customers VALUES (1, &#8217;2011-12-03&#8242;, 12500) , (1, &#8217;2011-10-07&#8242;, 15000) , (1, &#8217;2011-09-12&#8242;, 16000) , (2, &#8217;2011-07-11&#8242;, 900) , (2, &#8217;2011-09-13&#8242;, 18000) , (2, &#8217;2011-11-03&#8242;, 7000) , (3, &#8217;2011-01-29&#8242;, 19000) , (3, &#8217;2011-04-19&#8242;, 1000) , (3, &#8217;2011-07-09&#8242;, 12000) ; Let’s say, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=833&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Given a customer table:</p>
<p><code style="font-size:12px;"><span style="color:blue;">CREATE TABLE </span><span style="color:black;">Customers<br />
</span><span style="color:gray;">(</span><span style="color:black;">CustId </span><span style="color:blue;">INT</span><span style="color:gray;">, </span><span style="color:black;">OrderDate DATE</span><span style="color:gray;">, </span><span style="color:black;">OrderAmount MONEY</span><span style="color:gray;">) ;</span></code></p>
<p><span style="color:blue;">INSERT </span><span style="color:black;">Customers </span><span style="color:blue;">VALUES<br />
</span><span style="color:gray;">(</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-12-03&#8242;</span><span style="color:gray;">, </span><span style="color:black;">12500</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-10-07&#8242;</span><span style="color:gray;">, </span><span style="color:black;">15000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">1</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-09-12&#8242;</span><span style="color:gray;">, </span><span style="color:black;">16000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">2</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-07-11&#8242;</span><span style="color:gray;">, </span><span style="color:black;">900</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">2</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-09-13&#8242;</span><span style="color:gray;">, </span><span style="color:black;">18000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">2</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-11-03&#8242;</span><span style="color:gray;">, </span><span style="color:black;">7000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">3</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-01-29&#8242;</span><span style="color:gray;">, </span><span style="color:black;">19000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">3</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-04-19&#8242;</span><span style="color:gray;">, </span><span style="color:black;">1000</span><span style="color:gray;">)<br />
, (</span><span style="color:black;">3</span><span style="color:gray;">, </span><span style="color:red;">&#8217;2011-07-09&#8242;</span><span style="color:gray;">, </span><span style="color:black;">12000</span><span style="color:gray;">) ;<br />
</span></p>
<p>Let’s say, we want to retrieve all records along with a column showing the customer’s date of first purchase.</p>
<p>We could start by computing the date of first purchase for each customer.</p>
<p><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">CustId</span><span style="color:gray;">, </span><span style="color:magenta;">MIN</span><span style="color:gray;">(</span><span style="color:black;">OrderDate</span><span style="color:gray;">) </span><span style="color:black;">FirstPurchaseDate<br />
</span><span style="color:blue;">FROM   </span><span style="color:black;">Customers<br />
</span><span style="color:blue;">GROUP BY<br />
</span><span style="color:black;">CustId </span></code></p>
<p>Result set has one row per each customer.</p>
<p><a href="http://svangasql.files.wordpress.com/2011/12/image3.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image_thumb3.png?w=215&#038;h=114" alt="image" width="215" height="114" border="0" /></a></p>
<p>Joining this to the original table will return the expected results.</p>
<p><code style="font-size:12px;"><span style="color:blue;">SELECT </span><span style="color:black;">c.</span><span style="color:gray;">*, </span><span style="color:black;">firstD.FirstPurchaseDate<br />
</span><span style="color:blue;">FROM   </span><span style="color:black;">Customers c<br />
</span><span style="color:blue;">INNER JOIN<br />
</span><span style="color:gray;">(<br />
</span><span style="color:blue;">SELECT </span><span style="color:black;">CustId</span><span style="color:gray;">, </span><span style="color:magenta;">MIN</span><span style="color:gray;">(</span><span style="color:black;">OrderDate</span><span style="color:gray;">) </span><span style="color:black;">FirstPurchaseDate<br />
</span><span style="color:blue;">FROM   </span><span style="color:black;">Customers<br />
</span><span style="color:blue;">GROUP BY<br />
</span><span style="color:black;">CustId<br />
</span><span style="color:gray;">)</span><span style="color:black;">firstD<br />
</span><span style="color:blue;">ON </span><span style="color:black;">firstD.CustId </span><span style="color:blue;">= </span><span style="color:black;">c.CustId </span></code></p>
<p>Result set:</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image_thumb4.png?w=285&#038;h=166" alt="image" width="285" height="166" border="0" /></p>
<p>The query plan uses a nested join because of the join we were using the query above.</p>
<p><a href="http://svangasql.files.wordpress.com/2011/12/image4.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image_thumb5.png?w=513&#038;h=174" alt="image" width="513" height="174" border="0" /></a></p>
<p>We can achieve the same results using the <a href="http://msdn.microsoft.com/en-us/library/hh213018(v=sql.110).aspx" target="_blank">FIRST_VALUE</a>() function.</p>
<p><code style="font-size:12px;"><span style="color:blue;">SELECT<br />
</span><span style="color:black;">c.CustId</span><span style="color:gray;">, </span><span style="color:black;">c.OrderDate</span><span style="color:gray;">, </span><span style="color:black;">c.OrderAmount<br />
</span><span style="color:gray;">, </span><span style="color:black;">FIRST_VALUE</span><span style="color:gray;">(</span><span style="color:black;">OrderDate</span><span style="color:gray;">) </span><span style="color:blue;">OVER</span><span style="color:gray;">(</span><span style="color:black;">PARTITION </span><span style="color:blue;">BY </span><span style="color:black;">CustId </span><span style="color:blue;">ORDER BY </span><span style="color:black;">OrderDate</span><span style="color:gray;">) </span><span style="color:black;">CustomerSince<br />
</span><span style="color:blue;">FROM<br />
</span><span style="color:black;">Customers c<br />
</span></code></p>
<p>[PARTITON BY CustId], creates a partiton for each customer. [ORDER BY OrderDate] sorts each partition by the OrderDate. Now, from this ordered result set, FIRST_VALUE() returns the first value for each partition.</p>
<p>The query is easier to read and a join is not needed. Result: the nested loop is eliminated in the query plan. This could improve performance.</p>
<p><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image_thumb6.png?w=514&#038;h=91" alt="image" width="514" height="91" border="0" /></p>
<p>I&#8217;ll conclude with a question for you to understand <a href="http://msdn.microsoft.com/en-us/library/hh231517(v=sql.110).aspx" target="_blank">LAST_VALUE</a>(). From the same fictitious customer data, let&#8217;s say we want to compute the recent purchase date (as opposed to first purchase date from above example) of every customer. What would be the query? I welcome your response in the comments below.</p>
<p><a href="http://twitter.com/#!/SamuelVanga" target="_blank">@SamuelVanga</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/833/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/833/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/833/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=833&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2012/01/10/first_value-analytic-function-sql-server-2012/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Management Studio Split Tabs</title>
		<link>http://svangasql.wordpress.com/2012/01/03/management-studio-split-tabs/</link>
		<comments>http://svangasql.wordpress.com/2012/01/03/management-studio-split-tabs/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 12:30:00 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[management studio]]></category>

		<guid isPermaLink="false">https://svangasql.wordpress.com/?p=924</guid>
		<description><![CDATA[This is by far the simplest and silliest post ever, but i just figured how to create vertical tabs in management studio. When I learn something, you have to read it. I apologize, but you have to read it. As Ellen DeGeneres says, “if I see something… you have to see it” (YouTube Video). When [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=924&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is by far the simplest and silliest post ever, but i just figured how to create vertical tabs in management studio. When I learn something, you have to read it. I apologize, but you have to read it. As Ellen DeGeneres says, “if I see something… you have to see it” (<a href="http://ellen.warnerbros.com/2011/11/ellens_thoughts_on_the_virgin_diaries_1130.php" target="_blank">YouTube Video</a>).</p>
<p>When I want to compare scripts, I would open management studio in two separate windows and compare them. I knew there is an easier way, but didn’t know how to do that until recently.</p>
<p>Right click on a tab and choose – New Vertical Tab Group.</p>
<p><a href="http://svangasql.files.wordpress.com/2011/12/image6.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image_thumb8.png?w=382&#038;h=173" alt="image" width="382" height="173" border="0" /></a></p>
<p>Split vertical tabs can be seen in the image below.</p>
<p><a href="http://svangasql.files.wordpress.com/2011/12/image7.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image_thumb9.png?w=466&#038;h=223" alt="image" width="466" height="223" border="0" /></a></p>
<p>Note that you won’t see the new tab group options unless you have more than one tab open. Horizontal tabs can be created by clicking on New Horizontal Tab Group.</p>
<p>When done, you can reset the tabs to the original position by clicking on Move to Previous Tab Group.</p>
<p><a href="http://svangasql.files.wordpress.com/2011/12/image8.png"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;padding-top:0;border-width:0;" title="image" src="http://svangasql.files.wordpress.com/2011/12/image_thumb10.png?w=462&#038;h=160" alt="image" width="462" height="160" border="0" /></a></p>
<p>I’m sure you know this – but like I said earlier, if I learn something…!</p>
<p><a href="http://twitter.com/SamuelVanga" target="_blank">@me.</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/924/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/924/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/924/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/924/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/924/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/924/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/924/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/924/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/924/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/924/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/924/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/924/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/924/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/924/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=924&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2012/01/03/management-studio-split-tabs/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image_thumb8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image_thumb9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/12/image_thumb10.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Why doesn&#8217;t my gauge show correct values?</title>
		<link>http://svangasql.wordpress.com/2011/12/27/why-doesnt-my-gauge-show-correct-values/</link>
		<comments>http://svangasql.wordpress.com/2011/12/27/why-doesnt-my-gauge-show-correct-values/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 13:00:33 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[SSRS]]></category>
		<category><![CDATA[gauge]]></category>
		<category><![CDATA[scale properties]]></category>
		<category><![CDATA[ssrs]]></category>

		<guid isPermaLink="false">https://svangasql.wordpress.com/?p=118</guid>
		<description><![CDATA[Here is an issue I encountered recently while using gauge in reporting services. There are three gauges in the report one for each product; bikes, computers, and hardware. The value being showed is YTD sales and all gauges show a value of 100 for YTD Sales as seen below: However the actual YTD sales are [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=118&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is an issue I encountered recently while using gauge in reporting services.<br />
There are three gauges in the report one for each product; bikes, computers, and hardware. The value being showed is YTD sales and all gauges show a value of 100 for YTD Sales as seen below:</p>
<p><img src="https://lh4.googleusercontent.com/kXe-QYzjKCzLNZDrYeiO9It65Fi6nx_vlllZbyTwM1l53anNTQyl9Z8YFUKX_SPwwEhrZJdgYMAwe6Olu7JF8qTw8t57P2zAiwuHVlqUHEeS6cIlc-U" alt="" width="528" height="289" /></p>
<p>However the actual YTD sales are 100, 150 and 200 for bikes, computers, and hardware respectively. See the sample data below:<br />
<img src="https://lh6.googleusercontent.com/RkwUC8ss5lkfA6LFmL2mY-CT8uhFN4vPbBzC-GTtU2yFEwT9xuwUV_8Zr_ddanaTQDb6kuTU-GZvIGzImZK-5RTG5cJq2-WajybDwfPpA4gaBLqFOo4" alt="" width="486" height="231" /></p>
<p>Okay, why is this happening? I am glad you asked!</p>
<h2><strong>Minimum and Maximum values for chart:</strong></h2>
<p><strong></strong>Starting and ending values (0,100) on the gauge scale are controlled by minimum and maximum values that can be configured on the general page of scale properties. Right click on scale and select scale properties.<br />
<img src="https://lh5.googleusercontent.com/APd2xk4KTMIxdmHuBJor6ZBnHlLAtFjvCMhBnOnFi14nozKSMoz_U4dhSKFNxENdscXbNXK2I7MFpfn3_-VonoeYeRcJTOYGcIFxa_qDlT4Ji4sjrTQ" alt="" width="375" height="333" /><br />
<img src="https://lh5.googleusercontent.com/cfPPpk53R-9SbV9Vt6U-YNwRat3azn2zzZ6qVDn3nlJc-XBs45piZ92jQfmhDdRBXhE3UwMfKaPvi_cyGBrABeFuyQTN3TLPKUXf_eEXa-av9Nc7Rx8" alt="" width="576" height="453" /></p>
<p>Since maximum value is set to 100, scale doesn’t show beyond 100. And when the actual value (YTD sales in this case) exceeds the maximum value the pointer will be defaulted to point to the maximum value.</p>
<p>To resolve this problem, change the maximum value to the following expression.</p>
<p>=sum(Fields!YTDSales.Value)</p>
<p><a title="blog home " href="http://svangasql.wordpress.com" target="_blank">~Sam</a>.</p>
<p>Other Related Post: <a title="#SSRS error – An item with the same key has already been added" href="http://svangasql.wordpress.com/2011/11/10/ssrs-an-item-with-the-same-key-has-already-been-added/" target="_blank">SSRS Error &#8211; An item with the same key</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=118&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2011/12/27/why-doesnt-my-gauge-show-correct-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>

		<media:content url="https://lh4.googleusercontent.com/kXe-QYzjKCzLNZDrYeiO9It65Fi6nx_vlllZbyTwM1l53anNTQyl9Z8YFUKX_SPwwEhrZJdgYMAwe6Olu7JF8qTw8t57P2zAiwuHVlqUHEeS6cIlc-U" medium="image" />

		<media:content url="https://lh6.googleusercontent.com/RkwUC8ss5lkfA6LFmL2mY-CT8uhFN4vPbBzC-GTtU2yFEwT9xuwUV_8Zr_ddanaTQDb6kuTU-GZvIGzImZK-5RTG5cJq2-WajybDwfPpA4gaBLqFOo4" medium="image" />

		<media:content url="https://lh5.googleusercontent.com/APd2xk4KTMIxdmHuBJor6ZBnHlLAtFjvCMhBnOnFi14nozKSMoz_U4dhSKFNxENdscXbNXK2I7MFpfn3_-VonoeYeRcJTOYGcIFxa_qDlT4Ji4sjrTQ" medium="image" />

		<media:content url="https://lh5.googleusercontent.com/cfPPpk53R-9SbV9Vt6U-YNwRat3azn2zzZ6qVDn3nlJc-XBs45piZ92jQfmhDdRBXhE3UwMfKaPvi_cyGBrABeFuyQTN3TLPKUXf_eEXa-av9Nc7Rx8" medium="image" />
	</item>
		<item>
		<title>Full Load. Incremental Load. Whaaat?</title>
		<link>http://svangasql.wordpress.com/2011/12/20/difference-between-full-load-and-incremental-load/</link>
		<comments>http://svangasql.wordpress.com/2011/12/20/difference-between-full-load-and-incremental-load/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 12:30:10 +0000</pubDate>
		<dc:creator>Samuel Vanga</dc:creator>
				<category><![CDATA[Business Intelligence]]></category>
		<category><![CDATA[Data Warehouse]]></category>
		<category><![CDATA[full load]]></category>
		<category><![CDATA[incremental load]]></category>

		<guid isPermaLink="false">http://svangasql.wordpress.com/?p=847</guid>
		<description><![CDATA[Back when i was in school, me and a bunch of friends used to hangout at a diner. The diner was popular for its specials, which were displayed on a board outside the entrance.  The manager would roll in every day, wipe the board clean and list all the specials for that day. There will be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=847&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/duncan/3277295775/" target="_blank"><img style="background-image:none;padding-left:0;padding-right:0;display:inline;float:left;padding-top:0;border-width:0;" title="DinerSpecials4" src="http://svangasql.files.wordpress.com/2011/11/dinerspecials41.jpg?w=138&#038;h=148" alt="DinerSpecials4" width="138" height="148" align="left" border="0" /></a>Back when i was in school, me and a bunch of friends used to hangout at a diner. The diner was popular for its specials, which were displayed on a board outside the entrance.</p>
<p> The manager would roll in every day, wipe the board clean and list all the specials for that day. There will be a few new specials introduced daily, but most of them would be the same every day. Still the manager would erase everything completely (including those that weren&#8217;t changed) and rewrite. He was fine with having to spend a <strong>lot of time</strong> every day to do this, but he wanted to <strong>clearly</strong> display all the specials.</p>
<p>On the other hand, a manager at a different diner would erase only those specials that were discontinued and add the new ones. He didn&#8217;t mind that the specials were <strong>not clearly </strong>displayed, and only wanted to make the daily changes as <strong>quickly</strong> as possible.</p>
<p><strong>Destructive Load</strong></p>
<p>Also known as Full Load, is a process of completely destroying/deleting the existing data and reloading it from scratch. A lot of unchanged data is also deleted and reloaded in this process. But a destructive load ensures the highest data integrity easily.</p>
<p><em>“Delete destination data. Read data from source. Load into destination.”</em></p>
<h4><strong>Incremental Load </strong></h4>
<p><strong></strong>Incremental load is a process of loading data incrementally. Only new and changed data is loaded to the destination. Data that didn’t change will be left alone. Data integrity can be ensured in this process too, but ETL can get complicated.</p>
<p><em>“Read source data. Compare with destination. Filter for new and changed data. Write to destination.”. </em>I stole this line from <a title="Anatomy of an Incremental Load" href="http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/62063/" target="_blank">Anatomy of an Incremental Load</a> by Andy Leonard (<a title="Andy blog" href="http://sqlblog.com/blogs/andy_leonard/default.aspx" target="_blank">b</a>|<a title="Andy twitter" href="http://twitter.com/#!/andyleonard" target="_blank">t</a>).</p>
<h4><strong>Why Incremental?</strong></h4>
<p>A full load seems to be easiest the approach. <em>Right?. </em>Then why do we even care about incremental load?</p>
<ol>
<li><strong>Speed</strong>. Opting to do a full load on larger datasets will take a great amount of time and other server resources. Ideally all the data loads are performed overnight with the expectation of completing them before users can see the data the next day. The overnight window may not be enough time for the full load to complete.</li>
<li><strong>Preserving history</strong>. When dealing with a OLTP source that is not designed to keep history, a full load will remove history from the destination as well, since full load will remove all the records first, remember! So a full load will not allow you to preserve history in the data warehouse.</li>
</ol>
<h4><strong>Full Load vs. Incremental Load:</strong></h4>
<table style="width:719px;height:126px;" width="697" border="1" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td valign="top" width="133"> </td>
<td valign="top" width="299"><strong>Destructive Load</strong></td>
<td valign="top" width="307"><strong>Incremental Load</strong></td>
</tr>
<tr>
<td valign="top" width="133"><strong>How it works</strong></td>
<td valign="top" width="299">Deletes all rows and reload from scratch.</td>
<td valign="top" width="307">Only new or updated rows are processed</td>
</tr>
<tr>
<td valign="top" width="133"><strong>Time</strong></td>
<td valign="top" width="299">Requires more time.</td>
<td valign="top" width="307">Requires less time.</td>
</tr>
<tr>
<td valign="top" width="133"><strong>Data Integrity</strong></td>
<td valign="top" width="299">Can easily be guaranteed</td>
<td valign="top" width="307">Difficult. ETL must check for new/updated rows.</td>
</tr>
<tr>
<td valign="top" width="133"><strong>History</strong></td>
<td valign="top" width="299">Can be lost.</td>
<td valign="top" width="307">Retained.</td>
</tr>
</tbody>
</table>
<h4><strong><br />
Conclusion</strong></h4>
<p>Full load is the easiest way to load daily. But consumes a lot of time and other server resources. Incremental load processes only the new or changed data, so when time is of essence with larger data sets, incremental load is the way to go.</p>
<p>Next up&#8230;</p>
<p>In my next post, I&#8217;ll continue with scripts to do a full and incremental loads.</p>
<p><a href="http://twitter.com/SamuelVanga" target="_blank">@SamuelVanga</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/svangasql.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/svangasql.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/svangasql.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/svangasql.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/svangasql.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/svangasql.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/svangasql.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/svangasql.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/svangasql.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/svangasql.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/svangasql.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/svangasql.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/svangasql.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/svangasql.wordpress.com/847/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=svangasql.wordpress.com&amp;blog=27034556&amp;post=847&amp;subd=svangasql&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://svangasql.wordpress.com/2011/12/20/difference-between-full-load-and-incremental-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/daf12398d7b3942c5861922889e2fa7d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">samuelvanga</media:title>
		</media:content>

		<media:content url="http://svangasql.files.wordpress.com/2011/11/dinerspecials41.jpg" medium="image">
			<media:title type="html">DinerSpecials4</media:title>
		</media:content>
	</item>
	</channel>
</rss>
