<?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/"
	>

<channel>
	<title>Made2Mentor &#187; SSRS</title>
	<atom:link href="http://www.made2mentor.com/category/ssrs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.made2mentor.com</link>
	<description>Data Warehousing, Microsoft Business Intelligence, and Other Cool Stuff</description>
	<lastBuildDate>Thu, 19 Jan 2012 19:41:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Stop Creating Visual FoxPro Reports&#8230; Today</title>
		<link>http://www.made2mentor.com/2011/07/stop-writing-visual-foxpro-reports-today/</link>
		<comments>http://www.made2mentor.com/2011/07/stop-writing-visual-foxpro-reports-today/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 14:10:34 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Made2Manage]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=6306</guid>
		<description><![CDATA[
			
				
			
		
<p>Last week  I saw a discussion on the LinkedIn Made2Manage Group about the Pros and Cons of using SSRS vs. VFP Reporting, and it amazes me that people are still arguing about it. So, I thought I&#8217;d reaffirm a stance that I&#8217;ve had for many years, which is  VFP Reporting Must Die. </p>
<p>I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F07%2Fstop-writing-visual-foxpro-reports-today%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F07%2Fstop-writing-visual-foxpro-reports-today%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Last week  I saw a discussion on the <a href="http://www.linkedin.com">LinkedIn</a> Made2Manage Group about the Pros and Cons of using SSRS vs. VFP Reporting, and it amazes me that people are still arguing about it. So, I thought I&#8217;d reaffirm a stance that I&#8217;ve had for many years, which is <a href="http://www.made2mentor.com/2008/11/i-for-one-welcome-our-new-net-overlords-reporting/"> VFP Reporting Must Die</a>. </p>
<p>I&#8217;ve lamented <a href="http://www.made2mentor.com/2008/11/i-for-one-welcome-our-new-net-overlords-reporting/">Visual FoxPro&#8217;s limitations</a> in the past and I don&#8217;t want bore you by hashing them all out again. Let&#8217;s just hit the highlights. </p>
<ol>
<li>VFP reports are difficult to write and maintain.</li>
<li>VFP lacks chart and graph capability. </li>
<li>M2M report permissions management is tedious.</li>
</ol>
<p>However, in addition to that list, there are many other reasons you should curtail your use of Visual FoxPro.</p>
<h3>Technological Advantages</h3>
<p>There many technical advantages to using SSRS (or even Crystal Reports for that matter) over Visual FoxPro. In addition to graphing capabilities, SSRS also facilitates more interaction and customization. For example, you can easily create reports with drill down, and you can drill across to different reports as well. Let&#8217;s say for example, that your Operations Manager is looking at a Sales Order report, and wants to drill across to Purchase Order information tied to that Sales Order. Think you can do that with VFP? </p>
<h3>Develop Marketable Skills</h3>
<p>As I <a href="http://www.made2mentor.com/2011/06/what-is-your-focus/">mentioned last week</a>, VFP is a dying language and will never make you a more desirable employee in the market. The same applies if M2M adopts some other niche product as their new reporting strategy. Nobody is going to pay six figures for experience in some product nobody uses. Spend time focusing on T-SQL Programming and SSRS instead.</p>
<p>Remember, that it&#8217;s in Consona&#8217;s best interest to use a proprietary niche product as that generates additional consulting revenue for them. </p>
<h3>Ease of Use</h3>
<p>SSRS is so much easier to use than Visual FoxPro. It&#8217;s easier to learn and the tools are more polished. </p>
<h3>Re-usable Code</h3>
<p>All of these methods essentially boil down to one common denominator, T-SQL. The base T-SQL code is more easily extracted from SSRS, Crystal, etc. than from Visual FoxPro. Also, once you have the T-SQL, you can quickly re-create reports in any of the other methods including Qlickview, Tableau, and Excel. </p>
<p>Also, don&#8217;t forget to <a href="http://www.made2mentor.com/2010/12/database-views-using-powerpivot-with-problem-databases-part-2/">use Database Views</a> to make your code more manageable and easier to upgrade. </p>
<h3>SSRS is Less Expensive Than VFP</h3>
<p>SSRS is free with SQL Server 2005 and above. Did you actually license all of those copies of Visual FoxPro that you most likely have on your server and several workstations? If not, you&#8217;re breaking the law as those licenses cost approximately $500 a pop. </p>
<h3>SSRS Consulting is Less Expensive</h3>
<p>M2M charges $225 an hour for report customization work. One of the reasons they can is because there are relatively few people who are skilled in Visual FoxPro Reporting. SSRS Reporting skills are much more common and the competition drives prices down. Competent SSRS report writers can be hired for anywhere from $100 &#8211; $150 per hour on contract.</p>
<p>The Made2Manage people who recommend VFP Report Writing have three basic reasons that they cite for doing so. </p>
<h3>Using Anything Else is Not Supported</h3>
<p>Yes, this is true. Consona does not support the use of SSRS, Crystal, or even Excel for that matter. <strong>However, they don&#8217;t support their own VFP report customizations either</strong>. Consona&#8217;s contracts generally state that the contracted customization is only guaranteed to work on the version for which it was written. Be prepared, no matter which reporting method you use, to test and possibly edit your custom reports when migrating to a new version of M2M. If you&#8217;re using M2M Customized VFP reports, that may well mean more billing hours at $255 per. </p>
<h3>M2M Version 7 is Imminent</h3>
<p>Really? M2M has just begun to ask for Beta Testing volunteers. That process, especially when migrating to a new major release, will take a long time. And really, even if Version 7 was available today, how soon will most of you migrate anyway? I personally wouldn&#8217;t move until 7.01 (or after several service packs were issued) as new major releases are always problematic. Just ask the poor souls who were early adopters of version 6.0. </p>
<p>Yes, in a future version, M2M will get away from using Visual FoxPro. However, to the best of my knowledge they still haven&#8217;t announced what their new method will be. Even if it is some proprietary product, does it really matter anyway? They certainly aren&#8217;t going to migrate the entire product to Oracle or another database platform. Your SSRS reports will still work, and the time and effort invested in them is not wasted. </p>
<h3>Opening Reports in Another Program is Inconvenient</h3>
<p>You don&#8217;t need to open SSRS to use the reports. Those of you who regularly read this blog know that I&#8217;ve already shared how you can <a href="http://www.made2mentor.com/2011/05/opening-ssrs-reports-automatically-from-other-systems/">launch SSRS reports quickly and easily directly from M2M</a>. I know that people have done the same thing with Crystal Reports as well. </p>
<h3>One Exception&#8230;. </h3>
<p>The only time I edit a M2M VFP Report is when the requested customization is very small and easy to deliver. If a user wants another field from a table in the query, or some other small task, I&#8217;ll edit the current VFP report instead. I only do that when it&#8217;s more efficient than creating an entire report in SSRS or another medium. </p>
<p>What do you think? Anyone disagree with what I&#8217;ve said? What are you using as your reporting method and why? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2011/07/stop-writing-visual-foxpro-reports-today/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Opening SSRS Reports Automatically From Other Systems</title>
		<link>http://www.made2mentor.com/2011/05/opening-ssrs-reports-automatically-from-other-systems/</link>
		<comments>http://www.made2mentor.com/2011/05/opening-ssrs-reports-automatically-from-other-systems/#comments</comments>
		<pubDate>Fri, 27 May 2011 14:43:06 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Made2Manage]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Reports]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=6094</guid>
		<description><![CDATA[
			
				
			
		
<p>Users typically love SQL Server Reporting Services Reports (SSRS), especially if they&#8217;re accustomed to more primitive tools such as Visual FoxPro. However, One of the biggest complaints I hear about SSRS is that users want to be able to launch it directly from their ERP, accounting, and other systems. A conventional way to do this [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F05%2Fopening-ssrs-reports-automatically-from-other-systems%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F05%2Fopening-ssrs-reports-automatically-from-other-systems%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Users typically love SQL Server Reporting Services Reports (SSRS), especially if they&#8217;re accustomed to more primitive tools such as Visual FoxPro. However, One of the biggest complaints I hear about SSRS is that users want to be able to launch it directly from their ERP, accounting, and other systems. A conventional way to do this is through URL (Universal Resource Locator) manipulation.</p>
<p>Depending on the capabilities of the source system, reports can be launch from a button, combo box, list box, etc. and display a specific recordset based upon parameters you specify. The best way I&#8217;ve found to launch SSRS from Made2Manage is through VBA, which is a free optional module that any M2M customer can use. </p>
<h3>Steps to Create a URL Link Customization</h3>
<ol>
<li>Create a basic SSRS report. For this demo, I&#8217;ve created a very simple report which pulls a set of records from the Sales Order Master (SOMast) Table, which will be launched from the Sales Screen (SO). </li>
<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/05/ssrs_sales.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/05/ssrs_sales.png" alt="" title="ssrs_sales" width="528" height="300" class="aligncenter size-full wp-image-6100" /></a></p>
<li>Determine the actual URL link. I&#8217;m not going to go through each step of obtaining the proper URL because there&#8217;s an excellent <a href="http://www.mssqltips.com/tip.asp?tip=1336">step by step tutorial here.</a> In my case, the URL will be: </li>
<p>http://jeditemple/ReportServer/Pages/ReportViewer.aspx%2fBlog+Projects%2fSales+Details+for+URL+Link&#038;rs:Command=Render</p>
<p>Use the tutorial link instructions to find your URL, and the rest of this article is about how to integrate this into M2M. </p>
<li>Properly install VBA on the systems which will use this link. There are instructions on <a href="http://www.m2mexpert.com">M2MExpert</a> as well as on the M2M Install Disks, but beware that they are confusing and hard to follow. </li>
<li> Customize your M2VEvents.prj file in VBA. There is a downloadable class on M2M&#8217;s website for VBA programming. </li>
<li>You manipulate your M2VEvents.prj file by selecting Tools, Macros, and then Macros or by clicking on the Transfer button and typing VBPROJ. If your VBA project file is empty, you will have to access it by opening a screen in M2M, in this case SO, right clicking on the screen mnemonic, and selecting components. Choose INIT and the VBA Editor will open and the SO module will be created for you. </li>
<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/05/open_vba.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/05/open_vba.png" alt="" title="open_vba" width="288" height="340" class="aligncenter size-full wp-image-6105" /></a>	</p>
<li>Right click on the Module folder and select Insert and Module.</li>
<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/05/create_defaultmodule.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/05/create_defaultmodule.png" alt="" title="create_defaultmodule" width="339" height="264" class="aligncenter size-full wp-image-6109" /></a></p>
<li>Click on the new module and change the name to &#8220;DefaultModule&#8221; in the properties box.</li>
<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/05/vba_modules.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/05/vba_modules.png" alt="" title="vba_modules" width="226" height="257" class="aligncenter size-full wp-image-6106" /></a></p>
<li>Open the default module and paste the following code into it. This is a public function that is called by each module when creating the report URLs. Notice that I&#8217;ve ended it after the Blog Projects folder. My test SSRS Server only has the one folder on it at this time. The point is that this function returns the base portion of the URL for every report you intend to launch from M2M. The reason I&#8217;ve used the DefaultModule is if I decide to commission a new server, with a new name and such, I only need to change this base portion in one place, not in every module of the VBA project. Keep in mind that you will need to customize this code to match your server, folder structure, report names, etc. </li>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Public</span> <span style="color: #E56717; font-weight: bold;">Function</span> GetReportString() <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>
    GetReportString = <span style="color: #800000;">&quot;http://jeditemple/ReportServer/Pages/ReportViewer.aspx?%2fBlog+Projects%2f&quot;</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<li>Open the SO Module, press CTRL-A to select all of the text in it and delete that text. Then copy and paste in the following code into the SO module.</li>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #E56717; font-weight: bold;">Public</span> ReportStr <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>
<span style="color: #E56717; font-weight: bold;">Public</span> <span style="color: #E56717; font-weight: bold;">Function</span> INIT() <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Boolean</span>
&nbsp;
&nbsp;
   <span style="color: #8D38C9; font-weight: bold;">With</span> ThisForm.m2mPageFrame1.page1
     .addobject <span style="color: #800000;">&quot;lstReports&quot;</span>, <span style="color: #800000;">&quot;m2mListBox&quot;</span>
     .lstreports.Top = 300
     .lstreports.Left = 500
     .lstreports.Width = 80
     .lstreports.Height = 39
     .lstreports.Visible = <span style="color: #00C2FF; font-weight: bold;">True</span>
     .lstreports.AddItem <span style="color: #800000;">&quot;Sales&quot;</span>
    <span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">With</span>
&nbsp;
   ReportStr = GetReportString()
&nbsp;
    INIT = <span style="color: #00C2FF; font-weight: bold;">True</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span>
&nbsp;
<span style="color: #E56717; font-weight: bold;">Public</span> <span style="color: #E56717; font-weight: bold;">Function</span> M2mpageframe1_Page1_lstReports_CLICK() <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Boolean</span>
&nbsp;
<span style="color: #151B8D; font-weight: bold;">Dim</span> Rpt <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>, Param <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>, lcSomastSono <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">String</span>, Newsite <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Object</span>
&nbsp;
<span style="color: #151B8D; font-weight: bold;">Set</span> Newsite = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;InternetExplorer.application&quot;</span>)
&nbsp;
<span style="color: #8D38C9; font-weight: bold;">Select</span> <span style="color: #8D38C9; font-weight: bold;">Case</span> ThisForm.m2mPageFrame1.page1.lstreports.Value
&nbsp;
    <span style="color: #8D38C9; font-weight: bold;">Case</span> <span style="color: #800000;">&quot;Sales&quot;</span>
            lcSomastSono = Trim(ThisForm.gettablevalue(<span style="color: #800000;">&quot;somast&quot;</span>, <span style="color: #800000;">&quot;fsono&quot;</span>))
            Rpt = <span style="color: #800000;">&quot;Sales+Details+for+URL+Link&amp;rs:Command=Render&quot;</span>
            Param = <span style="color: #800000;">&quot;&amp;SONO=&quot;</span> + lcSomastSono
            Newsite.Navigate (ReportStr &amp; Rpt &amp; Param)
            Newsite.Visible = <span style="color: #00C2FF; font-weight: bold;">True</span>
    <span style="color: #8D38C9; font-weight: bold;">Case</span> <span style="color: #8D38C9; font-weight: bold;">Else</span>
            MsgBox (<span style="color: #800000;">&quot;Problem occured. Contact your administrator for help. &quot;</span>)
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #8D38C9; font-weight: bold;">Select</span>
    M2mpageframe1_Page1_lstReports_LICK = <span style="color: #00C2FF; font-weight: bold;">True</span>
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Function</span></pre></div></div>

<li>The INIT code draws a listbox on the SO form, assigns it&#8217;s properties, adds a selection to it called &#8220;Sales&#8221;. I chose a listbox because it&#8217;s one of the few controls on an M2M form that isn&#8217;t constrained by the Edit State of the screen. In other words, you can click on it even if you&#8217;re just viewing orders rather than editing them. I&#8217;d like to find a way to create something that looks like a hyperlink, but have not yet been successful.</li>
<li>The second function, which fires when the listbox is clicked, creates the URL from it&#8217;s basic parts. </li>
<ul>
<li>ReportStr as stated before is the base of your URL including your server name and base folder.</li>
<li>Rpt is the URL portion with the name of your report.</li>
<li>Param is the name of your parameter for this specific report. </li>
<li>lcSomastSono contains the record value, in this case the current Sales Order Number.</li>
</ul>
<li>If you&#8217;ve coded it properly, when you open the SO screen in M2M, you should see the following:</li>
<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/05/so_screen_listbox.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/05/so_screen_listbox.png" alt="" title="so_screen_listbox" width="320" height="220" class="aligncenter size-full wp-image-6129" /></a>
<li>If you&#8217;ve modified the code properly to connect to your SSRS server, then the report should open up to the corresponding sales order. In my case the URL created is shown below. Notice that I&#8217;ve bolded the custom parameter portion. </li>
<p>http://jeditemple/ReportServer/Pages/ReportViewer.aspx?%2fBlog+Projects%2fSales+Details+for+URL+Link&#038;rs:Command=Render<strong>&#038;SONO=000064</strong></p>
<li>There are additional parameter options shown in that tutorial which allow you to suppress the report toolbar, the parameter portion, etc. </li>
</ol>
<p>Although the code may look cumbersome, once you work through it, it&#8217;s very easy to understand and replicate. The <a href='http://www.made2mentor.com/wp-content/uploads/2011/05/VBA-Modules.zip'>VBA Modules</a> are available for download as well. </p>
<p>Any questions or suggestions for improvement? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2011/05/opening-ssrs-reports-automatically-from-other-systems/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Drawing a Blank. Dealing With Blank Values in SQL Server using NullIf and Coalesce</title>
		<link>http://www.made2mentor.com/2011/03/dealing-with-blank-values-in-sql-server-using-nullif-and-coalesce/</link>
		<comments>http://www.made2mentor.com/2011/03/dealing-with-blank-values-in-sql-server-using-nullif-and-coalesce/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 15:08:18 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Made2Manage]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[TOAD]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=5503</guid>
		<description><![CDATA[
			
				
			
		
<p> &#8220;Melodical Murray is a human musical instrument; he makes music by blowing his&#8230;blank&#8221; &#8211; Match Game</p>
<p>In the previous article I discussed the issues when working with Null-able fields in Joins and Where clauses. This article will deal with the problems of blank values. </p>
What About Blanks?
<p>Many systems forego the use of Null-able fields, but [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F03%2Fdealing-with-blank-values-in-sql-server-using-nullif-and-coalesce%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F03%2Fdealing-with-blank-values-in-sql-server-using-nullif-and-coalesce%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<blockquote><p> &#8220;Melodical Murray is a human musical instrument; he makes music by blowing his&#8230;blank&#8221; &#8211; Match Game</p></blockquote>
<p>In the <a href="http://www.made2mentor.com/2011/03/i-don%E2%80%99t-know-deal-with-it-nulls/">previous article</a> I discussed the issues when working with Null-able fields in Joins and Where clauses. This article will deal with the problems of blank values. </p>
<h3>What About Blanks?</h3>
<p>Many systems forego the use of Null-able fields, but instead use blank values. In fact, blank values are a bigger problem in M2M than Nulls. A common problem is with M2M Product Class values. For those that don&#8217;t use M2M, Product Class is similar to a Product Category that happens to be tied to general ledger accounts. Unfortunately, not every record in sales and other tables has a Product Class value and the value is blank. If you weren&#8217;t aware of this, run the following query against your M2M Database.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">DISTINCT</span> ARI.<span style="color: #202020;">fprodcl</span> ProductClass
<span style="color: #0000FF;">FROM</span>   dbo.<span style="color: #202020;">aritem</span> ARI</pre></div></div>

<p>The M2M Educational Database returns the following:<br />
<a href="http://www.made2mentor.com/wp-content/uploads/2011/03/blanks.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/blanks.png" alt="" title="blanks" width="106" height="208" class="aligncenter size-full wp-image-5521" /></a></p>
<p>In order to demonstrate this for those who don&#8217;t use M2M, I&#8217;ll run the following against the <a href='http://www.made2mentor.com/wp-content/uploads/2011/03/Kung-Fu-Database-Script.zip'>Kung Fu Database</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">UPDATE</span> dbo.<span style="color: #202020;">OrderDetails</span>
<span style="color: #0000FF;">SET</span>    ItemDescription <span style="color: #808080;">=</span> <span style="color: #FF0000;">''</span>
<span style="color: #0000FF;">WHERE</span>  orderid <span style="color: #808080;">=</span> <span style="color: #000;">4</span>
&nbsp;
<span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">DISTINCT</span> OD.<span style="color: #202020;">ItemDescription</span>
<span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">OrderDetails</span> OD</pre></div></div>

<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/blanks1.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/blanks1.png" alt="" title="blanks1" width="107" height="109" class="aligncenter size-full wp-image-5528" /></a><br />
So, how can we deal with the blank value (and the Null value as well?) Well, we could use a Case statement.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"> <span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">DISTINCT</span>
       <span style="color: #0000FF;">CASE</span>
         <span style="color: #0000FF;">WHEN</span> OD.<span style="color: #202020;">ItemDescription</span> <span style="color: #0000FF;">IS</span> <span style="color: #808080;">NULL</span> <span style="color: #0000FF;">THEN</span> <span style="color: #FF0000;">'..Null None'</span>
         <span style="color: #0000FF;">WHEN</span> OD.<span style="color: #202020;">ItemDescription</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">''</span> <span style="color: #0000FF;">THEN</span> <span style="color: #FF0000;">'..Blank None'</span>
         <span style="color: #0000FF;">ELSE</span> OD.<span style="color: #202020;">ItemDescription</span>
       <span style="color: #0000FF;">END</span>
         <span style="color: #0000FF;">AS</span> ItemDescription
  <span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">OrderDetails</span> OD</pre></div></div>

<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/blanks2.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/blanks2.png" alt="" title="blanks2" width="107" height="108" class="aligncenter size-full wp-image-5531" /></a><br />
Noticed that I assigned the value to Null and blank separately so you could see that it worked. Why did I use two periods before the text? I&#8217;ll explain that in a minute. The Case When works, but it&#8217;s wordy. There&#8217;s a much easier way to deal with both Blanks and Nulls. </p>
<h3>NullIf and Coalesce</h3>
<p>Let&#8217;s start with the <a href="http://msdn.microsoft.com/en-us/library/ms177562.aspx">NULLIF function</a>. NULLIF accepts two arguments and if the arguments are the same, then Null is returned, otherwise the first value is returned. Therefore, we can detect blanks with the following:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;">&nbsp;
<span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">NULLIF</span> <span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'A'</span>, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span>
 <span style="color: #008080;">-- Returns 'A'</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">NULLIF</span> <span style="color: #808080;">&#40;</span><span style="color: #FF0000;">''</span>, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span> 
<span style="color: #008080;">-- Returns Null</span>
<span style="color: #0000FF;">Declare</span> @Test <span style="color: #0000FF;">Char</span><span style="color: #808080;">&#40;</span><span style="color: #000;">5</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">NULLIF</span> <span style="color: #808080;">&#40;</span>@Test, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span> 
<span style="color: #008080;">-- Returns Null</span>
<span style="color: #008080;">-- I had to use a variable for the last test because the first argument must </span>
<span style="color: #008080;">-- have a known data type or an error will result.</span></pre></div></div>

<p>The second argument in this case is always &#8221; (blank). Why? If the field value is blank, the end result will be Null. Also, if the first argument is Null, that will return as Null as well. Make sense?</p>
<p>A Coalesce statement can then be used to replace the resulting Null value like so:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">NULLIF</span> <span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'A'</span>, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span> , <span style="color: #FF0000;">'..None'</span><span style="color: #808080;">&#41;</span> 
<span style="color: #008080;">-- Returns 'A'</span>
<span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">NULLIF</span> <span style="color: #808080;">&#40;</span><span style="color: #FF0000;">''</span>, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span> , <span style="color: #FF0000;">'..None'</span><span style="color: #808080;">&#41;</span> 
<span style="color: #008080;">--Returns '..None' </span>
<span style="color: #0000FF;">Declare</span> @Test <span style="color: #0000FF;">Char</span><span style="color: #808080;">&#40;</span><span style="color: #000;">5</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">SELECT</span>  <span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">NULLIF</span> <span style="color: #808080;">&#40;</span>@Test, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span> , <span style="color: #FF0000;">'..None'</span><span style="color: #808080;">&#41;</span> 
<span style="color: #008080;">-- Returns '..None'</span></pre></div></div>

<p>Let&#8217;s return to our original statement and substitute this method.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">DISTINCT</span>
       <span style="color: #0000FF;">coalesce</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">nullif</span> <span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">ItemDescription</span>, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF0000;">'..None'</span><span style="color: #808080;">&#41;</span>
         <span style="color: #0000FF;">AS</span> ItemDescription
  <span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">OrderDetails</span> OD</pre></div></div>

<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/blanks3.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/blanks3.png" alt="" title="blanks3" width="106" height="89" class="aligncenter size-full wp-image-5538" /></a></p>
<p>I have this process programmed as a Toad <a href="http://www.quest.com/toad-for-sql-server/">Toad for SQL Server</a> snippet. When I have time I&#8217;ll record a video showing how to use them. In this case, all I have to do is highlight the database field name, click the snippet, and Toad does the rest. So, why do I substitute text with leading periods? I do that primarily for <strong>generating available values in SSRS parameters</strong>. </p>
<p>When I go back and edit the first script (for M2M Product Classes) with this method, I get the following:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> <span style="color: #0000FF;">DISTINCT</span>
       ARI.<span style="color: #202020;">fprodcl</span> ProductClass
      ,<span style="color: #0000FF;">coalesce</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">nullif</span> <span style="color: #808080;">&#40;</span>ARI.<span style="color: #202020;">fprodcl</span>, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF0000;">'..None'</span><span style="color: #808080;">&#41;</span> FixedProductClass
  <span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">aritem</span> ARI
<span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> <span style="color: #0000FF;">coalesce</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">nullif</span> <span style="color: #808080;">&#40;</span>ARI.<span style="color: #202020;">fprodcl</span>, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF0000;">'..None'</span><span style="color: #808080;">&#41;</span></pre></div></div>

<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/blank4.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/blank4.png" alt="" title="blank4" width="188" height="208" class="aligncenter size-full wp-image-5539" /></a><br />
Which would your users rather see in a SSRS parameter drop down? </p>
<p>It&#8217;s important to note that blank (&#8221;) is an actual value, which is in fact equal to another blank, and can be used to join as well. However, in the case of Made2Manage, you shouldn&#8217;t expect to join your tables to the Product Class Table (INProd) with an Inner Join because you&#8217;ll &#8220;lose&#8221; records. That&#8217;s why I always link to INProd with a <a href="http://www.made2mentor.com/2011/02/different-types-of-joins/">Left Outer Join</a>. Would you like to see the invoice records that you&#8217;d lose in an Inner Join? Run the following against your database to find out.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> ARM.<span style="color: #202020;">fbcompany</span> <span style="color: #0000FF;">AS</span> BillToCompany
      ,ARI.<span style="color: #202020;">fcinvoice</span> <span style="color: #0000FF;">AS</span> InvoiceNo
      ,ARI.<span style="color: #202020;">fitem</span> <span style="color: #0000FF;">AS</span> ItemNo
      ,ARI.<span style="color: #202020;">fprodcl</span> <span style="color: #0000FF;">AS</span> ProductClass
      ,<span style="color: #FF00FF;">rtrim</span> <span style="color: #808080;">&#40;</span>ARI.<span style="color: #202020;">fpartno</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">AS</span> PartNo
      ,ARI.<span style="color: #202020;">frev</span> <span style="color: #0000FF;">AS</span> PartRev
      ,ARI.<span style="color: #202020;">ftotprice</span> <span style="color: #0000FF;">AS</span> NetExtInvoiced
  <span style="color: #0000FF;">FROM</span>   dbo.<span style="color: #202020;">armast</span> ARM
       <span style="color: #0000FF;">INNER</span> <span style="color: #808080;">JOIN</span>
         dbo.<span style="color: #202020;">aritem</span> ARI
       <span style="color: #0000FF;">ON</span> ARM.<span style="color: #202020;">FCINVOICE</span> <span style="color: #808080;">=</span> ARI.<span style="color: #202020;">FCINVOICE</span>
 <span style="color: #0000FF;">WHERE</span> ARM.<span style="color: #202020;">fcstatus</span> <span style="color: #808080;">&lt;&gt;</span> <span style="color: #FF0000;">'V'</span> <span style="color: #808080;">AND</span>
&nbsp;
       <span style="color: #0000FF;">coalesce</span> <span style="color: #808080;">&#40;</span><span style="color: #0000FF;">nullif</span> <span style="color: #808080;">&#40;</span>ARI.<span style="color: #202020;">fprodcl</span>, <span style="color: #FF0000;">''</span><span style="color: #808080;">&#41;</span>, <span style="color: #FF0000;">'..None'</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">'..None'</span> <span style="color: #008080;">-- Returns Blanks and Nulls</span></pre></div></div>

<p>In the M2M Educational Database, 19 records are returned. </p>
<p>So, in these two articles, I&#8217;ve demonstrated the problems of dealing with Nulls and Blanks in your database and how to deal with them. In the future, I&#8217;ll follow up with articles on creating and using Date tables and other more advanced T-SQL techniques. </p>
<p>Stay tuned! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2011/03/dealing-with-blank-values-in-sql-server-using-nullif-and-coalesce/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>I Don’t Know! Deal With It! (Nulls)</title>
		<link>http://www.made2mentor.com/2011/03/i-don%e2%80%99t-know-deal-with-it-nulls/</link>
		<comments>http://www.made2mentor.com/2011/03/i-don%e2%80%99t-know-deal-with-it-nulls/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 15:59:40 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Made2Manage]]></category>
		<category><![CDATA[Report Customization]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Reporting]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=5398</guid>
		<description><![CDATA[
			
				
			
		
<p>This topic has been done to death in many places, but I still get frequent questions about Null field issues in T-SQL. My purpose in this article is not to debate the definition of Null. Smarter men than I have already done so. </p>
<p>SQL Server Books Online indicates &#8220;A value of NULL indicates that the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F03%2Fi-don%25e2%2580%2599t-know-deal-with-it-nulls%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F03%2Fi-don%25e2%2580%2599t-know-deal-with-it-nulls%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>This topic has been done to death in many places, but I still get frequent questions about Null field issues in T-SQL. My purpose in this article is <strong>not to</strong> debate the definition of Null. Smarter men than I have already done so. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms191504.aspx">SQL Server Books Online</a> indicates &#8220;A value of NULL indicates that the value is unknown.&#8221; However, some disagree, most recently <a href="http://webbtechsolutions.com/2011/02/11/a-null-is-not-unknown/#respond">Joe Webb &#8211; Null is not Unknown</a>. Some argue that there should be <a href="http://sqlblog.com/blogs/hugo_kornelis/archive/2007/07/06/null-ndash-the-database-rsquo-s-black-hole.aspx">several different types of Null.</a></p>
<h3>Why Ask Why? </h3>
<p>As I said before, I don&#8217;t really care about the various interpretations of the Null value. I just know that they&#8217;re a pain to deal with. I have never received questions like this:</p>
<ul>
<li>What exactly is a Null? </li>
<li>What&#8217;s the definition of Null?</li>
</ul>
<p>The questions I get follow along these lines. </p>
<ul>
<li>Why am I losing records in this join? </li>
<li>Why is my total (or average) off in this query?</li>
<li>Why does my SSRS parameter list look funny? </li>
<li>Why won&#8217;t my parameters default like they should? </li>
</ul>
<p>So dear reader, as part of the <a href="http://www.made2mentor.com/t-sql-basics-series/">T-SQL Basics Series</a>, I am going to share what you need to know about dealing with Nulls rather than defining them. If you&#8217;d like to follow along, please download the <a href='http://www.made2mentor.com/wp-content/uploads/2011/03/Kung-Fu-Database-Script.zip'>Kung Fu Database Script</a>. </p>
<h3>Where Clause</h3>
<p>To start with, while people disagree about the definition of Null, everyone agrees what Null is not. It is not any of the following:</p>
<ul>
<li>0</li>
<li>blank</li>
<li>&#8221; (Empty String)</li>
<li>1/1/1900</li>
</ul>
<p>When most of us look at a Where clause, we only consider two options &#8211; True and False. However, SQL Server uses three value logic, True, False, and Unknown. Since Null represents an Unknown value any comparison to it results in Unknown, not True or False. Consider the following pseudo-code:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">Select</span> <span style="color: #808080;">*</span> <span style="color: #0000FF;">from</span> Employees <span style="color: #0000FF;">where</span> Salary <span style="color: #808080;">&gt;</span> <span style="color: #000;">500</span></pre></div></div>

<p>If the Salary field doesn&#8217;t allow nulls then it&#8217;s very easy to return the list of Employees which earn more than $500 per some time period. However, if Salary is a Nullable field, then any Employee without a Salary specification will not be returned. How could it be? You simply do not know whether they make more than $500 or not. </p>
<p>I find the easiest way for me to learn these concepts is to look at examples. Let&#8217;s start with the following base query from the Kung Fu Database.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> OD.<span style="color: #202020;">OrderID</span>, OD.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">LineNo</span><span style="color: #808080;">&#93;</span>, OD.<span style="color: #202020;">ProductID</span>, OD.<span style="color: #202020;">ItemDescription</span>, OD.<span style="color: #202020;">OrderQty</span>, OD.<span style="color: #202020;">Discount</span>, OD.<span style="color: #202020;">ListPrice</span>
<span style="color: #0000FF;">FROM</span>   dbo.<span style="color: #202020;">OrderDetails</span> OD</pre></div></div>

<p><div id="attachment_5423" class="wp-caption aligncenter" style="width: 502px"><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/null1.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/null1.png" alt="" title="null1" width="492" height="149" class="size-full wp-image-5423" /></a><p class="wp-caption-text">Null values are hightlighted. </p></div><br />
Returns: 6 Records. This is the total data set.</p>
<p>Now consider the following:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> OD.<span style="color: #202020;">OrderID</span>, OD.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">LineNo</span><span style="color: #808080;">&#93;</span>, OD.<span style="color: #202020;">ProductID</span>, OD.<span style="color: #202020;">ItemDescription</span>, OD.<span style="color: #202020;">OrderQty</span>, OD.<span style="color: #202020;">Discount</span>, OD.<span style="color: #202020;">ListPrice</span>
<span style="color: #0000FF;">FROM</span>   dbo.<span style="color: #202020;">OrderDetails</span> OD
&nbsp;
<span style="color: #0000FF;">WHERE</span>  OD.<span style="color: #202020;">OrderQty</span> <span style="color: #808080;">&gt;=</span> <span style="color: #000;">1</span></pre></div></div>

<p>Returns: 4 Records. Those with Null Values for OrderQty are ignored.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> OD.<span style="color: #202020;">OrderID</span>, OD.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">LineNo</span><span style="color: #808080;">&#93;</span>, OD.<span style="color: #202020;">ProductID</span>, OD.<span style="color: #202020;">ItemDescription</span>, OD.<span style="color: #202020;">OrderQty</span>, OD.<span style="color: #202020;">Discount</span>, OD.<span style="color: #202020;">ListPrice</span>
<span style="color: #0000FF;">FROM</span>   dbo.<span style="color: #202020;">OrderDetails</span> OD
&nbsp;
<span style="color: #0000FF;">WHERE</span>  OD.<span style="color: #202020;">OrderQty</span> <span style="color: #808080;">&lt;</span> <span style="color: #000;">1</span></pre></div></div>

<p>Returns: 0 Records. Comparing any value to Null results in Unknown and those those records are not returned.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> OD.<span style="color: #202020;">OrderID</span>, OD.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">LineNo</span><span style="color: #808080;">&#93;</span>, OD.<span style="color: #202020;">ProductID</span>, OD.<span style="color: #202020;">ItemDescription</span>, OD.<span style="color: #202020;">OrderQty</span>, OD.<span style="color: #202020;">Discount</span>, OD.<span style="color: #202020;">ListPrice</span>
<span style="color: #0000FF;">FROM</span>   dbo.<span style="color: #202020;">OrderDetails</span> OD
&nbsp;
<span style="color: #0000FF;">WHERE</span>  OD.<span style="color: #202020;">OrderQty</span> <span style="color: #808080;">=</span> <span style="color: #808080;">NULL</span></pre></div></div>

<p>Well, logically <strong>this should return 2 records, right</strong>? After all, you are asking for those records with Null values for OrderQty. However, the correct answer is <strong>0 records</strong>. The reason is simple.<strong> Comparing any value to Null (even another Null) returns Unknown</strong>. This may seem confusing, but logically it makes sense. Consider my Salary example above. If Bob and Dave both have Null Salary values, do they earn the same amount? Obviously, there&#8217;s no way to know. Therefore, the query evaluates to Unknown for those records and they aren&#8217;t returned. So, how can we return the Null records?</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> OD.<span style="color: #202020;">OrderID</span>, OD.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">LineNo</span><span style="color: #808080;">&#93;</span>, OD.<span style="color: #202020;">ProductID</span>, OD.<span style="color: #202020;">ItemDescription</span>, OD.<span style="color: #202020;">OrderQty</span>, OD.<span style="color: #202020;">Discount</span>, OD.<span style="color: #202020;">ListPrice</span>
<span style="color: #0000FF;">FROM</span>   dbo.<span style="color: #202020;">OrderDetails</span> OD
&nbsp;
<span style="color: #0000FF;">WHERE</span>  OD.<span style="color: #202020;">OrderQty</span> <span style="color: #0000FF;">IS</span> <span style="color: #808080;">NULL</span></pre></div></div>

<p>Returns: 2 Records. For the same reason, we could have used &#8220;IS NOT NULL&#8221; and 4 records would return. </p>
<p>So, what if we want to return any records with a quantity less than 1 and include Null Values? Well, you could write that query like this:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> OD.<span style="color: #202020;">OrderID</span>, OD.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">LineNo</span><span style="color: #808080;">&#93;</span>, OD.<span style="color: #202020;">ProductID</span>, OD.<span style="color: #202020;">ItemDescription</span>, OD.<span style="color: #202020;">OrderQty</span>, OD.<span style="color: #202020;">Discount</span>, OD.<span style="color: #202020;">ListPrice</span>
<span style="color: #0000FF;">FROM</span>   dbo.<span style="color: #202020;">OrderDetails</span> OD
&nbsp;
<span style="color: #0000FF;">WHERE</span>  OD.<span style="color: #202020;">OrderQty</span> <span style="color: #808080;">&lt;</span> <span style="color: #000;">1</span> 
<span style="color: #808080;">OR</span> OD.<span style="color: #202020;">OrderQty</span> <span style="color: #0000FF;">IS</span> <span style="color: #808080;">NULL</span></pre></div></div>

<p>Returns: 2 Records. </p>
<h3>Replacing Null Values with ISNULL or COALESCE</H3><br />
So that works, but it&#8217;s wordy. How can we more easily deal with nulls? Well, we can replace them with an actual value by using <a href="http://msdn.microsoft.com/en-us/library/ms190349.aspx">COALESCE</a> or <a href="http://msdn.microsoft.com/en-us/library/ms184325.aspx">ISNULL</a>. Each function returns the first Non-Null value found in the list of arguments. For example, SELECT ISNULL(NULL, 25) returns 25. However, SELECT ISNULL(NULL, NULL) returns Null. </p>
<p>Some people prefer IsNUll because the name of the function is more understable to them and it has been shown to have a very slight performance advantage. However, I use Coalesce because IsNull is limited to 2 arguments, whereas COALESE doesn&#8217;t have any realistic limit. SELECT COALESCE(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 7) still returns 7. Remember that it returns the first non-null value. Therefore, SELECT COALESCE(NULL, 3, NULL, NULL, NULL, 7) only returns the first value which is 3. </p>
<p>So, you may use Coalesce to simply these comparisons as well as for aesthetic reasons. Consider the previous Kung Fu Database query re-written with Coalesce. I&#8217;ve formatted it vertically to emphasize the difference.</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span>
  OD.<span style="color: #202020;">OrderID</span>
 ,OD.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">LineNo</span><span style="color: #808080;">&#93;</span>
 ,OD.<span style="color: #202020;">ProductID</span>
 ,OD.<span style="color: #202020;">ItemDescription</span>
 ,<span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">OrderQty</span>,<span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> OrderQty <span style="color: #008080;">-- COALESCE AND ALIASED</span>
 ,OD.<span style="color: #202020;">Discount</span>
 ,OD.<span style="color: #202020;">ListPrice</span>
<span style="color: #0000FF;">FROM</span>
  dbo.<span style="color: #202020;">OrderDetails</span> OD
<span style="color: #0000FF;">WHERE</span>
  <span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">OrderQty</span>,<span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">&lt;</span> <span style="color: #000;">1</span></pre></div></div>

<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/null2.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/null2.png" alt="" title="null2" width="479" height="66" class="aligncenter size-full wp-image-5444" /></a><br />
Who determines whether or not you should replace the field like this? For the most part, the business user. So, if the business user provides the proper substitution values, the query may be written like this:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span>
  OD.<span style="color: #202020;">OrderID</span>
 ,OD.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">LineNo</span><span style="color: #808080;">&#93;</span>
 ,<span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">ProductID</span>, <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> ProductID
 ,<span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">ItemDescription</span>, <span style="color: #FF0000;">'None'</span><span style="color: #808080;">&#41;</span> ItemDescription
 ,<span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">OrderQty</span>, <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> OrderQty
 ,<span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">Discount</span>, <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> Discount
 ,<span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">ListPrice</span>, <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> ListPrice
<span style="color: #0000FF;">FROM</span> dbo.<span style="color: #202020;">OrderDetails</span> OD</pre></div></div>

<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/null3.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/null3.png" alt="" title="null3" width="477" height="148" class="aligncenter size-full wp-image-5449" /></a></p>
<h3>Joining on NULL-able Columns</h3>
<p>So, I&#8217;ve demonstrated how Null values can cause problems in the Where clause. For the same reasons, <strong>joining</strong> on Null-able columns is problematic as well. Consider my example Order Details table which allows a Null value for ProductID. Consider the following script:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span>
  OD.<span style="color: #202020;">OrderID</span>
 ,OD.<span style="color: #808080;">&#91;</span><span style="color: #0000FF;">LineNo</span><span style="color: #808080;">&#93;</span>
 ,OD.<span style="color: #202020;">ProductID</span>
 ,P.<span style="color: #202020;">ProductID</span>
 ,P.<span style="color: #202020;">ProdName</span>
 ,OD.<span style="color: #202020;">ItemDescription</span>
 ,OD.<span style="color: #202020;">OrderQty</span>
 ,OD.<span style="color: #202020;">Discount</span>
 ,OD.<span style="color: #202020;">ListPrice</span>
<span style="color: #0000FF;">FROM</span>
    dbo.<span style="color: #202020;">OrderDetails</span> OD
  <span style="color: #0000FF;">FULL</span> <span style="color: #808080;">OUTER</span> <span style="color: #808080;">JOIN</span>
    dbo.<span style="color: #202020;">Products</span> P
  <span style="color: #0000FF;">ON</span> P.<span style="color: #202020;">ProductID</span> <span style="color: #808080;">=</span> OD.<span style="color: #202020;">ProductID</span></pre></div></div>

<p>If that were written as your standard inner join, the recordset would lose the indicated record.<br />
<a href="http://www.made2mentor.com/wp-content/uploads/2011/03/null7.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/null7.png" alt="" title="null7" width="660" height="149" class="aligncenter size-full wp-image-5483" /></a></p>
<h3>Grouping, Sorting, and Aggregates</h3>
<p>In regards to Group By and Order By, Null values are considered equal. Meaning that all of the Null values are treated as one entity and are grouped and ordered as such.</p>
<p>Consider the following queries and result sets:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span> OD.<span style="color: #202020;">OrderQty</span>
<span style="color: #0000FF;">FROM</span>   dbo.<span style="color: #202020;">OrderDetails</span> OD
&nbsp;
<span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> OD.<span style="color: #202020;">OrderQty</span></pre></div></div>

<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/NULL4.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/NULL4.png" alt="" title="NULL4" width="76" height="149" class="aligncenter size-full wp-image-5452" /></a></p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span>   OD.<span style="color: #202020;">OrderQty</span>
<span style="color: #0000FF;">FROM</span>     dbo.<span style="color: #202020;">OrderDetails</span> OD
&nbsp;
<span style="color: #0000FF;">GROUP</span> <span style="color: #0000FF;">BY</span> OD.<span style="color: #202020;">OrderQty</span></pre></div></div>

<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/null5.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/null5.png" alt="" title="null5" width="69" height="85" class="aligncenter size-full wp-image-5453" /></a></p>
<p><strong>Aggregate Functions</strong><br />
Aggregate functions such as COUNT, SUM, and AVG ignore Null values. However, one can use COUNT(*) which will count all records. Consider the following query:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">SELECT</span>
  <span style="color: #FF00FF;">SUM</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">OrderQty</span><span style="color: #808080;">&#41;</span> QtySum
  ,<span style="color: #FF00FF;">Avg</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">cast</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">OrderQty</span> <span style="color: #0000FF;">as</span> <span style="color: #0000FF;">decimal</span> <span style="color: #808080;">&#40;</span><span style="color: #000;">4</span>,<span style="color: #000;">2</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> NullAvg
  ,<span style="color: #FF00FF;">Avg</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">cast</span><span style="color: #808080;">&#40;</span><span style="color: #0000FF;">COALESCE</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">OrderQty</span>,<span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">as</span> <span style="color: #0000FF;">decimal</span> <span style="color: #808080;">&#40;</span><span style="color: #000;">4</span>,<span style="color: #000;">2</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span> ZeroAvg 
 ,<span style="color: #FF00FF;">COUNT</span><span style="color: #808080;">&#40;</span>OD.<span style="color: #202020;">OrderQty</span><span style="color: #808080;">&#41;</span> QtyCount
 ,<span style="color: #FF00FF;">COUNT</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">*</span><span style="color: #808080;">&#41;</span> TotalCount
<span style="color: #0000FF;">FROM</span>
  dbo.<span style="color: #202020;">OrderDetails</span> OD</pre></div></div>

<p><a href="http://www.made2mentor.com/wp-content/uploads/2011/03/null62.png"><img src="http://www.made2mentor.com/wp-content/uploads/2011/03/null62.png" alt="" title="null6" width="315" height="49" class="aligncenter size-full wp-image-5462" /></a><br />
I had to Cast the quantities as decimals, because otherwise the values would have been rounded to 1. If you do the math, you&#8217;ll see that aggregate functions only considered the four records with non-null values. This is particularly noticeable when you compare the NullAvg and the ZeroAvg. The ZeroAvg actually divides the total by 7 instead of 4. </p>
<p>In this article, I&#8217;ve attempted through the use of many examples to describe the issues when working with Null values and how to deal with them. In the next article, I&#8217;ll discuss how to deal with blank values in Joins, Where clauses, and when creating parameter lists for SQL Server Reporting Services. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2011/03/i-don%e2%80%99t-know-deal-with-it-nulls/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ooh! Ooh! Pick Me! SQL Rally</title>
		<link>http://www.made2mentor.com/2011/01/ooh-ooh-pick-me-sql-rally/</link>
		<comments>http://www.made2mentor.com/2011/01/ooh-ooh-pick-me-sql-rally/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 19:36:12 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[PASS]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=4744</guid>
		<description><![CDATA[
			
				
			
		
<p class="wp-caption-text">Pick Me Mr. Kotter!</p>
<p>SQL Rally is a brand new event for this year. It&#8217;s kind of a hybrid between the PASS Summit and a SQL Saturday. It&#8217;s fairly low cost and being held May 11-13 in Orlando, Florida. </p>
<p>Anyway, the reason for this post is completely self serving. I really want to present at [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F01%2Fooh-ooh-pick-me-sql-rally%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2011%2F01%2Fooh-ooh-pick-me-sql-rally%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div id="attachment_4745" class="wp-caption aligncenter" style="width: 506px"><a href="http://www.made2mentor.com/wp-content/uploads/2011/01/oooh_pick_me.jpg"><img src="http://www.made2mentor.com/wp-content/uploads/2011/01/oooh_pick_me.jpg" alt="horshack" title="oooh_pick_me" width="496" height="639" class="size-full wp-image-4745" /></a><p class="wp-caption-text">Pick Me Mr. Kotter!</p></div>
<p><a href="http://www.sqlpass.org/sqlrally/2011/">SQL Rally</a> is a brand new event for this year. It&#8217;s kind of a hybrid between the PASS Summit and a SQL Saturday. It&#8217;s <a href="http://www.sqlpass.org/sqlrally/2011/Register.aspx">fairly low cost</a> and being held May 11-13 in Orlando, Florida. </p>
<p>Anyway, the reason for this post is completely self serving. I really want to present at this event. Please <a href="http://www.zoomerang.com/Survey/WEB22BNWLDC2D6/">register to vote</a> and vote for my sessions. Mine are in the 10th section in the SSRS category. The abstracts I submitted are:</p>
<p>Title:	<strong>Choose Your Own (Reporting) Adventure – SSRS Survivor Series</strong><br />
Abstract:	Create a story of guided analytics using Reporting Services drill down, drill through, and expressions. Sure, you may be using drill down already, but I’ll show you how to make the most of Reporting Services interactions, and more importantly how to avoid becoming dragon chow at the end.</p>
<p>Title:	<strong>The Power of Parameters &#8211; SSRS Survivor Series</strong><br />
Abstract:	Want to know the best techniques to help your user narrow their search in the most efficient ways possible? Come watch me demonstrate which parameter techniques are best for certain situations and field types. Real world problems and applications are stressed, and I’ll demonstrate why some commonly accepted methods simply do not work and should be avoided.</p>
<p>&#8211;My name is Made2Mentor, and I approved this message. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2011/01/ooh-ooh-pick-me-sql-rally/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Saturday Dallas #56 Re-Cap</title>
		<link>http://www.made2mentor.com/2010/10/sql-saturday-dallas-56-re-cap/</link>
		<comments>http://www.made2mentor.com/2010/10/sql-saturday-dallas-56-re-cap/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 14:00:55 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Presenting]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=3977</guid>
		<description><![CDATA[
			
				
			
		
<p class="wp-caption-text">Ryan, Vic, and yours truly. </p>
<p>SQL Saturday #56 BI Edition went off without a hitch last Saturday. Those who read this blog, probably remember the awesome experience I had at my first SQL Saturday. </p>
<p>Once again, everything went wonderfully. Our event was scaled back this time which translated into fewer hassles. Microsoft and Artis [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2010%2F10%2Fsql-saturday-dallas-56-re-cap%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2010%2F10%2Fsql-saturday-dallas-56-re-cap%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<div id="attachment_3987" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.made2mentor.com/wp-content/uploads/2010/10/dave_ryan_vic.jpg"><img src="http://www.made2mentor.com/wp-content/uploads/2010/10/dave_ryan_vic.jpg" alt="Dave Ryan Vic" title="dave_ryan_vic" width="640" height="427" class="size-full wp-image-3987" /></a><p class="wp-caption-text">Ryan, Vic, and yours truly. </p></div>
<p><a href="http://www.sqlsaturday.com/56/eventhome.aspx">SQL Saturday #56 BI Edition</a> went off without a hitch last Saturday. Those who read this blog, probably remember the awesome experience I had at my <a href="http://www.made2mentor.com/2010/05/my-sqlsaturday-experience/">first SQL Saturday</a>. </p>
<p>Once again, everything went wonderfully. Our event was scaled back this time which translated into fewer hassles. Microsoft and <a href="http://www.artisconsulting.com/Pages/Home.aspx">Artis Consulting</a> were our only sponsors. Microsoft provided the building, took care of security, check in, and all of those little things that need to be handled the day of the event, while Artis provided food for breakfast and lunch. This left many of us on the planning committee with more time to enjoy the day with fewer things to worry about.<br />
<div id="attachment_3989" class="wp-caption aligncenter" style="width: 650px"><a href="http://www.made2mentor.com/wp-content/uploads/2010/10/me_explaining.jpg"><img src="http://www.made2mentor.com/wp-content/uploads/2010/10/me_explaining.jpg" alt="Me" title="me_explaining" width="640" height="427" class="size-full wp-image-3989" /></a><p class="wp-caption-text">Leading people astray.... </p></div></p>
<p>I was asked to present two topics this time: </p>
<ul>
<li>Creating Interactive Dashboards with PowerPivot. Slicing Your Way to Data Nirvana</li>
<li>Who, What, Where. The Power of SSRS Parameters</li>
</ul>
<p>My presentations went very well, and were well received. My evaluations were great, but I do know that I need more practice. That shouldn&#8217;t be too hard to get as I thoroughly enjoy it anyway. </p>
<p>I wanted to take a moment to thank a few people. I want to thank the folks on the volunteer committee and NTSSUG board. Folks like <a href="http://northtexas.sqlpass.org/AboutUs/tabid/241/Default.aspx">Sri Sridharan</a>, <a href="http://midnightdba.itbookworm.com/">Sean and Jen McCown</a>, <a href="http://www.timmitchell.net/">Tim Mitchell</a>, <a href="http://twitter.com/SQLJackal">Vic Prabhu</a>, <a href="http://www.ryanjadams.com/">Ryan Adams</a>, and Ganesh Gopal. I&#8217;d also like to thank Rakesh Kanjani (Rocky) for taking pictures for the event and Andy Eggers who works harder on event day than any other three people I know.  </p>
<p>Let me let you in on a little tip. Go to the after party. They&#8217;re not crowded, though they should be. Yes, I know you&#8217;re tired after a full day of learning and networking, but go anyway. The best conversations, both technical and non-technical, can be had there. People are ready to relax, open up, and the atmosphere is great for networking. </p>
<p>A note to those who attended my sessions at SQL Saturday, and the week prior at Consona Connect 2010: I haven&#8217;t forgotten that I owe both groups a few blog posts going into more detail on the topics I presented. I promise to have those out by the end of next week. </p>
<p>I&#8217;ll also be blogging about <a href="http://www.made2mentor.com/2010/10/announcing-project-m-data-analytics/"> M-Data Analytics</a> as well as a posts regarding <a href="http://www.sqlpass.org/summit/na2010/">PASS Summit</a> which I&#8217;ll be attending for the first time this year. </p>
<p>I&#8217;m so <a href="http://www.made2mentor.com/2010/07/ive-got-a-golden-ticket/">thrilled to be going</a>, and you should go too. Tomorrow, I&#8217;m going to tell you why. </p>
<p>Stay Tuned! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2010/10/sql-saturday-dallas-56-re-cap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server Maintenance Plans for Small/Mid-sized Businesses FAQs</title>
		<link>http://www.made2mentor.com/2010/08/sql-server-maintenance-plans-for-smallmid-sized-businesses-faqs/</link>
		<comments>http://www.made2mentor.com/2010/08/sql-server-maintenance-plans-for-smallmid-sized-businesses-faqs/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 14:00:06 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Made2Manage]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[Data Corruption]]></category>
		<category><![CDATA[Data Integrity]]></category>
		<category><![CDATA[Disaster Recovery]]></category>
		<category><![CDATA[Performance Tuning]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=3614</guid>
		<description><![CDATA[
			
				
			
		
<p>I get a ton of questions and calls about SQL Server Maintenance issues from Administrators who just want their server to work and be protected. They&#8217;re not interested in the intricate structure of a transaction log, how to use wait stats, etc. While many database administrators who read this article will disagree or perhaps outright [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2010%2F08%2Fsql-server-maintenance-plans-for-smallmid-sized-businesses-faqs%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2010%2F08%2Fsql-server-maintenance-plans-for-smallmid-sized-businesses-faqs%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I get a ton of questions and calls about SQL Server Maintenance issues from Administrators who just want their server to work and be protected. They&#8217;re not interested in the intricate structure of a transaction log, how to use wait stats, etc. While many database administrators who read this article will disagree or perhaps outright flame me, (cough <a href="http://www.networkworld.com/community/mccown">Sean McCown</a> cough <img src='http://www.made2mentor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ) I feel that SQL maintenance plans are a very effective means for non-dbas to protect their data. </p>
<p>Rather than recreate tutorials that others have already written and take the same screenshots they provide, I&#8217;ll link you to them and suggest settings that are applicable to most M2M companies. Keep in mind that every situation is different, what I&#8217;m offering are very general guidelines. </p>
<h3>Maintenance Plan Tutorials</h3>
<p>The simplest way to maintain a SQL Server is to use the Maintenance Plan Wizard. Please select a link to instructions for your server version. Each site has an easy to follow tutorial. These types of tutorials will explain the purpose of most settings, but will not make recommendations because so many factors come into play.  </p>
<ul>
<li><a href="http://www.databasejournal.com/features/mssql/article.php/3530486/Working-with-the-SQL-Server-2000-Maintenance-Plan-Wizard.htm">SQL Server 2000</a></li>
<li><a href="http://www.databasejournal.com/features/mssql/article.php/3656816/SQL-2005-Maintenance-Wizard-Part-1.htm">SQL Server 2005 Part One</a>, <a href="http://www.databasejournal.com/features/mssql/article.php/3662636/SQL-2005-Maintenance-Wizard-Part-2.htm">two</a>, and <a href="http://www.databasejournal.com/features/mssql/article.php/3665841/Microsoft-SQL-2005-Maintenance-Wizard-Part-3.htm">three</a>.</li>
<li><a href="http://www.sql-server-performance.com/articles/dba/Overview_of_Maintenance_Plans_in_SQL_Server_2008_p1.aspx">SQL Server 2008</a></li>
</ul>
<h3>Database Mail</h3>
<p>Before moving on to the guidelines, make sure you also have database mail set up for notifications. A Maintenance Plan isn&#8217;t any good if it isn&#8217;t running successfully. Unless you want to manually check the server each day, you&#8217;ll need to set up notifications. </p>
<p>For SQL Server 2000, there are a couple of ways to do this neither of which is particularly appetizing. The easiest way is to use <a href="http://blogs.techrepublic.com.com/datacenter/?p=363">Outlook on your server</a>. However, ideally you shouldn&#8217;t be running anything but SQL Server on your SQL Server (more on that in a future article). You can send mail <a href="http://www.howtogeek.com/howto/database/sending-automated-job-email-notifications-in-sql-server-with-smtp/">using stored procedures</a> using SQL Server but I don&#8217;t expect that many of you would want to deal with that. It&#8217;s a mess and also a perfect excuse to nag your boss to approve a SQL Server upgrade. </p>
<p>SQL Server 2005 and 2008 have mail capability built in and it&#8217;s very easy to set up. Visit the following sites for complete walkthroughs:</p>
<ul>
<li><a href="http://www.sql-server-performance.com/articles/dba/email_functionality_p1.aspx">SQL Server 2005</a></li>
<li><a href="http://www.codeproject.com/KB/database/SQLServer2008DatabaseMail.aspx">SQL Server 2008</a></li>
</ul>
<h3>FAQs and Guidelines for Small/Mid-sized Companies </h3>
<p>Alright, now that the groundwork is out of the way, my recommendations follow. Companies which use M2M tend to be small to mid-sized. Most M2M databases are between 5 and 100GB and with data smaller databases like these, performance isn&#8217;t a huge issue. These guidelines assume that you fit this profile. The following questions are frequently asked of me, and most of them are business related, rather than technical. </p>
<p><strong>Which recovery model should I use? </strong><br />
I respond to this question with a question. &#8220;How much data can you afford to lose?&#8221; If you are willing to risk losing a day&#8217;s productivity, then Simple Recovery Model is fine and you won&#8217;t have to worry about transaction log backups. However, if you need better protection than that, use the Full Recovery Model. I have some databases set to the Simple Recovery Model because I simply don&#8217;t care about them. One example is WebSense. Would it be the end of the world if I lost 24 hours employee web surfing records? Not really. I wrote a more detailed explanation of recovery models <a href="http://www.made2mentor.com/2010/04/sql-server-recovery-models-and-backup-types/">here. </a></p>
<p><strong>How often should I do transaction log backups? </strong><br />
Once again, how much work can you afford to lose? Most of the M2M sites I&#8217;ve dealt with which use the Full Recovery Model, schedule transaction log backups every 15 to 60 minutes. Keep in mind that whatever time span you set for this represents the maximum amount of work you can lose. Get your backups (full and t-log) off the server as quickly as possible. I&#8217;ve looked at more than a few M2M Servers where the backups were kept on the same drive volume as the database. This is a waste of time. </p>
<p><strong>How long should I keep backups? </strong><br />
I hate to keep echoing questions back at you, but how long do you need them? A couple of the companies I do business with keep their full database backups almost a year. However, they move them to tape every day and only have one or two copies internally. Read further about <a href="http://www.made2mentor.com/2010/04/disaster-recovery-options-for-smallmedium-sized-businesses/">backup options for details. </a></p>
<p><strong>Do I have to worry about SQL Database Integrity?</strong><br />
I often receive blank looks when I mention integrity checks. M2M recommends moving from Visual FoxPro to SQL Server because it is more stable. However, that doesn&#8217;t mean you can&#8217;t get data corruption. I recommend checking database integrity before your nightly full backup. If any database fails an integrity check contact a qualified database administrator to deal with it. Unlike the old days of re-indexing, purifying, and packing Visual FoxPro tables, SQL database integrity failures can be a serious problem. If you decide to try to handle that yourself, look for articles written by known experts such as the great <a href="http://www.sqlskills.com/blogs/paul/">Paul Randal.</a> While we&#8217;re on the subject of data integrity, make sure to check that the maintenance plan verifes the integrity of the backups as well. However, you still need to perform test restores to be absolutely sure that your backups are sound. </p>
<p><strong>Do I need to re-index my SQL Databases? </strong></p>
<p>Once again, when I answer this question I am assuming that you have a database between 5 and 100GB and have decent server hardware as well. The answer is yes, you should index your SQL Databases. I index mine on weekends, but I could just as soon index it on weeknights as it doesn&#8217;t take much time with a database that small. You won&#8217;t notice much a difference in performance after indexing either as M2M is not heavily indexed. Since time isn&#8217;t a factor here, set your indexes to rebuild the indexes which effectively drops and then recreates them. Also, go ahead and update statistics as well. </p>
<p><a href="http://www.made2mentor.com/wp-content/uploads/2010/08/paul_randal.jpg"><img src="http://www.made2mentor.com/wp-content/uploads/2010/08/paul_randal-150x150.jpg" alt="" title="paul_randal" width="150" height="150" class="alignleft size-thumbnail wp-image-3675" /></a><strong>Can I shrink my database and make it smaller? </strong><br />
No, do not ever shrink your database unless you have a compelling reason to do so. Unless your database grew for a specific reason do not shrink your database because it will then have to grow again. These processes are expensive and unnecessary. A typical scenario which may require a shrink would be an over-sized transaction log which went without a backup for a long time. You can purchase that shirt <a href="http://www.zazzle.com/shrink_that_db_and_an_angel_loses_its_wings_tshirt-235048690607701425">here</a>.</p>
<p><strong>How often should I perform a test restore? </strong><br />
Do you have a good backup? Are you sure??? You know that scene in <a href="http://www.imdb.com/title/tt0104952/">My Cousin Vinny</a> where Vinny and Mona Lisa are arguing about the dripping faucet? </p>
<blockquote><p>Mona Lisa: Did it ever occur to you that it could be turned off and drip at the same time?<br />
Vinny: No, because if you turned it off, it wouldn&#8217;t drip.<br />
Mona Lisa: Maybe it&#8217;s broken.<br />
Vinny: Is that what you&#8217;re saying? It&#8217;s broken?<br />
Mona Lisa: Yeah, that&#8217;s it; it&#8217;s broken.<br />
Vinny: You sure?<br />
Mona Lisa: I&#8217;m positive.<br />
Vinny: Maybe you didn&#8217;t twist it hard enough.<br />
Mona Lisa: I twisted it just right.<br />
Vinny: How can you be so sure?<br />
Mona Lisa: If you will look in the manual, you will see that this particular model faucet requires a range of 10-16 foot pounds of torque. I routinely twist the maximum allowable torquage.<br />
Vinny: How can you be sure you used 16 foot pounds of torque?<br />
Mona Lisa: Because I used a Craftsman model 1019 Laboratory edition, signature series torque wrench. The kind used by Cal Tech High Energy physicists, and NASA engineers.<br />
Vinny: In that case, how can you be sure that&#8217;s accurate?<br />
Mona Lisa: Because a split second before the torque wrench was applied to the faucet handle, it had been calibrated by top members of the state and federal Departments of Weights and Measures, to be dead-on balls accurate. Here&#8217;s the certificate of validation.<br />
Vinny: &#8220;Dead-on balls accurate&#8221;?<br />
Mona Lisa: It&#8217;s an industry term.</p></blockquote>
<p>The scene is funny, but the point is valid. How can you be sure that your backups are &#8220;Dead-on balls accurate?&#8221; Perform test restores. If you haven&#8217;t performed a test restore then the backup cannot be relied upon. I can hear the question forming in your mind, &#8220;Do I have to perform a test restore every single day?&#8221; No, I don&#8217;t expect you to check every single backup to verify that it restores. However, once or twice a month isn&#8217;t out of line. After all, with the size of most of our databases, it only takes 10 to 15 minutes to perform a test restore anyway. </p>
<p>In future articles, I&#8217;ll show you how to perform database restores using both full and transaction log backups. I&#8217;ll also document the system I&#8217;m currently using. I backup both a SQL 2000 and 2008 R2 database server using t-sql scripts, do-it-yourself compression and encryption, as well as nightly test restores.  It will take me awhile to document, since I have to re-set all of that up from scratch at home. I&#8217;ll try to post these articles before Consona Connect. </p>
<p>Any questions? Did I forget anything? Any disagreements? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2010/08/sql-server-maintenance-plans-for-smallmid-sized-businesses-faqs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using User Defined Functions to Pre-Format Fields</title>
		<link>http://www.made2mentor.com/2010/06/using-user-defined-functions-to-pre-format-fields/</link>
		<comments>http://www.made2mentor.com/2010/06/using-user-defined-functions-to-pre-format-fields/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 15:00:22 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Made2Manage]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Crystal Reports]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Reports]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=3458</guid>
		<description><![CDATA[
			
				
			
		
<p>Some DBAs would cringe at what I’m about to tell you, but I often use T-SQL to format my data prior to presenting it in a report. Many experts feel that data formatting should always be done in the presentation layer. There are a couple of reasons why I do this.</p>

I re-use as much code [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2010%2F06%2Fusing-user-defined-functions-to-pre-format-fields%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2010%2F06%2Fusing-user-defined-functions-to-pre-format-fields%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Some DBAs would cringe at what I’m about to tell you, but I often use T-SQL to format my data prior to presenting it in a report. Many experts feel that data formatting should always be done in the presentation layer. There are a couple of reasons why I do this.</p>
<ol>
<li>I re-use as much code as I can. I create base templates for most of the main modules in M2M (Sales, Purchasing, Accts Payable, Etc) and these templates include the formatting code. This results in a professional, standardized image to my reports.</li>
<li>I report using many different programs as my presentation layer and I want to re-use my scripts for all of them. </li>
</ol>
<p>Consider the following script:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">Select</span> fsono, fenumber, frelease, fpartno <span style="color: #0000FF;">from</span> m2mdata50..<span style="color: #202020;">sorels</span></pre></div></div>

<p>The first few rows of data from the M2M educational database return:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;">000001	001	000	CP2080 
000001	002	000	FF204W 
000002	001	000	WF201R 
000002	001	001	WF201R 
000002	001	002	WF201R 
000002	001	003	WF201R 
000002	001	004	WF201R</pre></div></div>

<p>Do you notice the distraction of the leading zeros? When searching for a sales order number, does anyone really enter &#8220;000003&#8243;? These are a problem in most of the modules of M2M. As I mentioned before, many DBAs feel that you should remove them via formatting in the presentation program of your choice. However, I regularly create reports in SQL Reporting Services, Crystal Reports, Visual FoxPro, and Excel. This means that if I don’t pre-format with T-SQL, I will have to adapt the presentation later manually, which and the technique will be different for each reporting media. This is time consuming and error prone.</p>
<p>As always, please read my <a href="http://www.made2mentor.com/2010/03/standard-disclaimer/">standard disclaimer</a> before implementing any code from my site. Using T-SQL, you could strip the preceding zeros like this:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">select</span> <span style="color: #FF00FF;">substring</span><span style="color: #808080;">&#40;</span>fsono, <span style="color: #FF00FF;">patindex</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'%[^0]%'</span>,fsono<span style="color: #808080;">&#41;</span>, <span style="color: #000;">10</span><span style="color: #808080;">&#41;</span> SONo,
<span style="color: #FF00FF;">substring</span><span style="color: #808080;">&#40;</span>fenumber, <span style="color: #FF00FF;">patindex</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'%[^0]%'</span>,fenumber<span style="color: #808080;">&#41;</span>, <span style="color: #000;">10</span><span style="color: #808080;">&#41;</span> SOItemNo,
<span style="color: #FF00FF;">substring</span><span style="color: #808080;">&#40;</span>frelease, <span style="color: #FF00FF;">patindex</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'%[^0]%'</span>,frelease<span style="color: #808080;">&#41;</span>, <span style="color: #000;">10</span><span style="color: #808080;">&#41;</span> Release,
fpartno PartNo <span style="color: #0000FF;">from</span> m2mdata50..<span style="color: #202020;">sorels</span></pre></div></div>

<p>Which yields this:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #000;">1</span>	<span style="color: #000;">1</span>	000	CP2080 
<span style="color: #000;">1</span>	<span style="color: #000;">2</span>	000	FF204W 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	000	WF201R 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	<span style="color: #000;">1</span>	WF201R 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	<span style="color: #000;">2</span>	WF201R 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	<span style="color: #000;">3</span>	WF201R 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	<span style="color: #000;">4</span>	WF201R</pre></div></div>

<p>That works, but it’s too wordy for me. A better option is to use a User Defined Function (UDF) to clean up the data. I’ve demonstrated <a href="http://www.made2mentor.com/2010/01/using-user-defined-functions-to-suppress-blank-dates/">how to write these</a> in the past. </p>
<p>Consider the following:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">FUNCTION</span> RemoveZeros<span style="color: #808080;">&#40;</span>@ZeroField <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">25</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
  <span style="color: #0000FF;">RETURNS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">12</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">AS</span>
  <span style="color: #0000FF;">BEGIN</span>
    <span style="color: #0000FF;">DECLARE</span> @ZerosRemoved   <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">12</span><span style="color: #808080;">&#41;</span>
    <span style="color: #0000FF;">DECLARE</span> @Length   <span style="color: #0000FF;">INT</span>
    <span style="color: #0000FF;">SET</span> @length <span style="color: #808080;">=</span> <span style="color: #FF00FF;">len</span><span style="color: #808080;">&#40;</span>@ZeroField<span style="color: #808080;">&#41;</span>
    <span style="color: #0000FF;">SELECT</span> @ZerosRemoved <span style="color: #808080;">=</span>
             <span style="color: #0000FF;">CASE</span>
               <span style="color: #0000FF;">When</span> @ZeroField <span style="color: #808080;">=</span> <span style="color: #FF0000;">'000'</span>
               <span style="color: #0000FF;">then</span>
                 <span style="color: #FF0000;">'M'</span>
               <span style="color: #0000FF;">WHEN</span> @Length <span style="color: #808080;">&gt;</span> <span style="color: #000;">0</span>
               <span style="color: #0000FF;">THEN</span>
                 <span style="color: #FF00FF;">substring</span><span style="color: #808080;">&#40;</span>
                   @ZeroField,
                   <span style="color: #FF00FF;">patindex</span><span style="color: #808080;">&#40;</span>
                     <span style="color: #FF0000;">'%[^0]%'</span>,
                     @ZeroField<span style="color: #808080;">&#41;</span>,
                   @Length<span style="color: #808080;">&#41;</span>
               <span style="color: #0000FF;">ELSE</span>
                 <span style="color: #FF0000;">''</span>
             <span style="color: #0000FF;">END</span>
    <span style="color: #0000FF;">RETURN</span> @ZerosRemoved
  <span style="color: #0000FF;">END</span></pre></div></div>

<p>Which produces output like this:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #000;">1</span>	<span style="color: #000;">1</span>	M	CP2080 
<span style="color: #000;">1</span>	<span style="color: #000;">2</span>	M	FF204W 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	M	WF201R 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	<span style="color: #000;">1</span>	WF201R 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	<span style="color: #000;">2</span>	WF201R 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	<span style="color: #000;">3</span>	WF201R 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	<span style="color: #000;">4</span>	WF201R</pre></div></div>

<p>Can you see the possibilities? You can use this UDF in other modules such as shipping and invoicing as well.  It works particularly well in shipping because the item numbers are 6 digits. Have any of you ever had a shipper with a million line items on it?</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">Select</span> fshipno, fitemno, fpartno <span style="color: #0000FF;">from</span> m2mdata50..<span style="color: #202020;">shitem</span>
&nbsp;
000001	000001	CP2080 
000002	000001	FF204W 
000003	000001	L20100 
000003	000002	L20200 
000004	000001	EF120100P</pre></div></div>

<p>Becomes:</p>

<div class="wp_syntax"><div class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #0000FF;">Select</span> dbo.<span style="color: #202020;">removezeros</span><span style="color: #808080;">&#40;</span>fshipno<span style="color: #808080;">&#41;</span> ShipNo,
       dbo.<span style="color: #202020;">removezeros</span><span style="color: #808080;">&#40;</span>fitemno<span style="color: #808080;">&#41;</span> ItemNo,
       fpartno PartNo
<span style="color: #0000FF;">from</span> m2mdata50..<span style="color: #202020;">shitem</span>
&nbsp;
<span style="color: #000;">1</span>	<span style="color: #000;">1</span>	CP2080 
<span style="color: #000;">2</span>	<span style="color: #000;">1</span>	FF204W 
<span style="color: #000;">3</span>	<span style="color: #000;">1</span>	L20100 
<span style="color: #000;">3</span>	<span style="color: #000;">2</span>	L20200 
<span style="color: #000;">4</span>	<span style="color: #000;">1</span>	EF120100P</pre></div></div>

<p>The performance impact is negligible, and the both the script and the output are well formatted. </p>
<p>What other UDF’s do you think would be useful for M2M reporting? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2010/06/using-user-defined-functions-to-pre-format-fields/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Five Reasons You Should Volunteer With Your Local SQL User Group and Host a SQL Saturday</title>
		<link>http://www.made2mentor.com/2010/05/five-reasons-you-should-volunteer-with-your-local-sql-user-group-and-host-a-sql-saturday/</link>
		<comments>http://www.made2mentor.com/2010/05/five-reasons-you-should-volunteer-with-your-local-sql-user-group-and-host-a-sql-saturday/#comments</comments>
		<pubDate>Wed, 19 May 2010 13:00:25 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SSRS]]></category>
		<category><![CDATA[Education]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Thankful]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=3381</guid>
		<description><![CDATA[
			
				
			
		
<p>
I took the plunge this year and started volunteering for the North Texas SQL Server User Group. Originally I started attending because I wanted to learn more about SQL Server, but it didn’t take long before I realized that there was so much more to be gained from being there. </p>
Why should you volunteer with [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2010%2F05%2Ffive-reasons-you-should-volunteer-with-your-local-sql-user-group-and-host-a-sql-saturday%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2010%2F05%2Ffive-reasons-you-should-volunteer-with-your-local-sql-user-group-and-host-a-sql-saturday%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.made2mentor.com/wp-content/uploads/2010/05/dave_sql_saturday_small.jpg"><img src="http://www.made2mentor.com/wp-content/uploads/2010/05/dave_sql_saturday_small.jpg" alt="" title="dave_sql_saturday_small" width="296" height="396" class="alignleft size-full wp-image-3383" /></a><br />
I took the plunge this year and started volunteering for the <a href="http://northtexas.sqlpass.org/">North Texas SQL Server User Group</a>. Originally I started attending because I wanted to learn more about SQL Server, but it didn’t take long before I realized that there was so much more to be gained from being there. </p>
<h2>Why should you volunteer with your local user group?</h2>
<h3>You get to meet really cool people. </h3>
<p>I realize that I don’t know most of you personally, but I think most of you are like me. The reason you read this blog is because you want to know more about your profession than the average person. That’s likely how you found me in the first place. The folks at your user group are just like us. They are passionate about their craft, fascinated by technology, and want to be the best they can be. However after you get to know them better, you’ll also find that many of them are caring and really fun to be around. </p>
<p>I can hear you saying, “Yeah David, but I can get all of that by going to the monthly meetings, why should I bother to volunteer?” I attended this user group for almost 2 years before I volunteered and had no idea who these people really were. I had talked to them of course, but you only get to know them as you work <strong>WITH</strong> them. You become a member of the club, feel like you belong, and they let their hair down. </p>
<h3>You can network with some of the best minds in SQL Server. </h3>
<p>Some of the best minds in SQL Server present at SQL Saturdays. They fly in at their own expense to share their knowledge and network with you. These are the people who write the books on SQL Server, MVPs and other luminaries. When you volunteer, you can get exclusive access to them.  </p>
<p>Also, remember those smart, motivated folks in your local area that I mentioned above? On the volunteer committee I’m working side by side with two Microsoft MVPs and more folks who are on their way to becoming MVPs. I’m spending weekends volunteering with them and getting to know them well. These are the folks who can help you find your next job. </p>
<h3>Do you want to eventually give SQL presentations? You should start by volunteering.</h3>
<p>When I chose the name Made2Mentor, it wasn’t without a great deal of thought. I have always taught others and mentored them in something that I was good at. I’m learning SQL Server rapidly and intend to begin presenting on various aspects of it. </p>
<p>If you’ve already volunteered, and I intend to continue to do so, approaching the leader of the User Group is an easy matter because you’ve already worked extensively with him. I may even present a session at the next SQL Saturday. </p>
<h3>You can learn so much from the other volunteers, maybe even find a mentor or two.</h3>
<p>I’ve already received a ton of help from people on the volunteer committee that I would not have been able to get had I not volunteered. While I know you can get basic help from forums or Google searches, you get so much more from people with whom you’ve built a relationship. </p>
<p>Once you get to know them, they’ll take the time to look at your problem personally and guide you in the right direction. It’s not just technical help either. Many of us are very bright technically, but lack the soft skills. Many of the people who run these groups have already mastered the soft skills of interpersonal communication, and you can learn from them. It is only natural that they eventually become your mentors. </p>
<h3>Volunteering makes you feel good about yourself. </h3>
<p>I know that I often focus on the career aspects of networking, but it’s not all about your personal gain. It feels good to give to the community, to help the other volunteers without worrying about what you’ll get from it. There’s a real sense of achievement which comes from hosting an event like SQL Saturday and knowing that you had a part in it. </p>
<p>So, I encourage you to join your local SQL Server User Group and volunteer. If you have the opportunity to volunteer for a project such as a SQL Saturday, jump in and do your best. There are so many benefits, that you’ll find it’s totally worth it. </p>
<p>I’d like to my fellow members of the planning committee <a href="http://northtexas.sqlpass.org/AboutUs/tabid/241/Default.aspx">Sri Sridharan</a>, <a href="http://midnightdba.itbookworm.com/">Sean and Jen McCown</a>, <a href="http://www.timmitchell.net/">Tim Mitchell</a>, <a href="http://twitter.com/SQLJackal">Vic Prabhu</a>, <a href="http://www.ryanjadams.com/">Ryan Adams</a>, as well as the rest of the volunteers for SQL Saturday for making the experience great. </p>
<p>By the way, if any of you are coming to <a href="http://www.sqlsaturday.com/35/eventhome.aspx">SQL Saturday Dallas</a>, then look me up. I’ll be running all over the place, helping to get things done. <img src='http://www.made2mentor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>PS. To my regular readers, I apologize about my lack of blogging lately. Obviously I’ve been busy with SQL Saturday and I’ve had a great deal of pressure with my work the past few weeks. I’ll be back on track and will continue with the disaster recovery theme next week. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2010/05/five-reasons-you-should-volunteer-with-your-local-sql-user-group-and-host-a-sql-saturday/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>BI Ethics</title>
		<link>http://www.made2mentor.com/2009/12/bi_ethics/</link>
		<comments>http://www.made2mentor.com/2009/12/bi_ethics/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 18:46:49 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Made2Manage]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SSRS]]></category>

		<guid isPermaLink="false">http://www.made2mentor.com/?p=2401</guid>
		<description><![CDATA[
			
				
			
		
<p>The ethics of business intelligence is a touchy subject that many people don’t want to talk about.  However, more attention in the past several years has been given to this subject mostly due to ethics scandals at huge companies such as Enron, Tyco, and WorldCom.  The Sarbanes-Oxley Act came about because of such [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.made2mentor.com%2F2009%2F12%2Fbi_ethics%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.made2mentor.com%2F2009%2F12%2Fbi_ethics%2F&amp;source=Made2Mentor&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The ethics of business intelligence is a touchy subject that many people don’t want to talk about.  However, more attention in the past several years has been given to this subject mostly due to ethics scandals at huge companies such as Enron, Tyco, and WorldCom.  The <a href="http://en.wikipedia.org/wiki/Sarbanes%E2%80%93Oxley_Act">Sarbanes-Oxley Act</a> came about because of such scandals and the billions of dollars they cost investors as well as the decrease in investor confidence in the stock markets, but it only applies to publicly held companies.  </p>
<p>This is all well documented, and related information can be found all over the web.  Recently a Code of Conduct for DBAs was proposed by SQL DBA, <a href="http://www.simple-talk.com/sql/database-administration/a-code-of-conduct-for-dbas/">Brad McGehee</a>.  This is an excellent, albeit broad set of guidelines for DBA behavior.  </p>
<p>My <a href="http://www.made2mentor.com/2009/12/when-being-right-may-be-wrong/">last article</a> discusses a relatively benign situation where a decision was made how to calculate and provide statistics.  In this article, I’d like to focus on business intelligence.  What do you as a Business Intelligence Expert do when asked to provide questionable information?  I’ll give the following example to facilitate discussion.  </p>
<p>The Accounting Manager of your organization requests a report which details Accounts Receivable Aging.  You code the SQL for the report creating groups of invoices that are 30 days, 60 days, 90 days, and more past due.  You include an attractive chart and send the report to the Manager for approval.  He reviews it and confides in you that his new bonus structure (or perhaps even his job) is dependent upon these numbers.  He requests that since ACME Rockets is always late, Wile E. Coyote is always out in the desert chasing the Road Runner instead of paying bills, that they should be removed from the report.  His reasoning is that no matter how well the manager performs his job, ACME will never pay in less than 90 days and this drastically lowers his rating.   </p>
<p>Think about that for a second….   I’ll wait. </p>
<p>Now let’s suggest that the Accounting Manager is your direct supervisor.  You may actually lose your job if you refuse.  Look deep within yourself, did the answer change? </p>
<p>Anyway, the following poll is anonymous.  What would you do?  Feel free to explain why you answered the way you did in the comments.<br />
Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.made2mentor.com/2009/12/bi_ethics/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

