<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Best &amp; Worst Practices</title>
        <link>http://weblogs.sqlteam.com/markc/category/34.aspx</link>
        <description>Best &amp; Worst Practices</description>
        <language>en-US</language>
        <copyright>AjarnMark</copyright>
        <managingEditor>Mark@CaldwellBiz.com</managingEditor>
        <generator>Subtext Version 1.9.4.0</generator>
        <item>
            <title>How to Return Record #n</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2008/01/24/60464.aspx</link>
            <description>&lt;p&gt;I got this question in email a while ago, and it seems to come up quite a bit, which frankly surprises me.  I guess it's because I almost never* write an application where I need to retrieve the 10th (or whatever number) record.  I am always trying to retrieve the record for Joe Smith, or Order Number 1256487, or the last record entered on 12/31/2007, or... well, you get the point.  I am frequently searching for records based on a data value.  But I rarely, if ever, have had to go looking for the &lt;strong&gt;n&lt;/strong&gt;th record.&lt;/p&gt;  &lt;p&gt;I see this question often enough that it makes me wonder if it isn't a school assignment somewhere.  It sounds like the type of question you would get in school (or &lt;strong&gt;maybe&lt;/strong&gt; in an interview)... "Write a SQL statement that will return the 17th record in the table."  Or maybe it comes from people using Access where they had the FIRST() statement...&lt;strong&gt;UGH!&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Of course the problem with this is that there is no such thing as the first, or 17th or &lt;strong&gt;n&lt;/strong&gt;th record by itself.  There is no guarantee in a SQL Server database (nor probably any relational database) that records will be retrieved in a particular order without the use of an &lt;em&gt;ORDER BY&lt;/em&gt; clause**.  And if you cannot guarantee the order that records will be retrieved, then the ordinal position of a record is completely useless.&lt;/p&gt;  &lt;p&gt;Now, after all of that, if you still think that you have a need to get the &lt;strong&gt;n&lt;/strong&gt;th record, here is my suggestion.  First add your ORDER BY clause.  And second, read Graz's article entitled &lt;a href="http://www.sqlteam.com/article/whats-after-top" target="_blank"&gt;What's After TOP?&lt;/a&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;* The one exception is where I want the SQL Server to handle paging for me instead of my front-end system.  If you are in that position, then I suggest you do a search on the term &lt;em&gt;paging&lt;/em&gt; on the &lt;a href="http://www.sqlteam.com/" target="_blank"&gt;SQLTeam&lt;/a&gt; web site.  There are numerous articles about how to accomplish this.&lt;/p&gt;  &lt;p&gt;** OK, someone is likely going to point out that if you put a Clustered Index on the field that you want it to sort by, that it will retrieve the data in that order.  For a single table retrieval, you &lt;strong&gt;may&lt;/strong&gt; be right, but I wouldn't bet my career on that always working out, especially when joining other tables with clustered indexes.  Also, you will end up in a world of hurt if you rely on that mechanism and down the road your Production DBA decides to redefine the clustered index onto different columns for overall system performance.&lt;/p&gt;&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/60464.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2008/01/24/60464.aspx</guid>
            <pubDate>Fri, 25 Jan 2008 07:52:40 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2008/01/24/60464.aspx#feedback</comments>
            <slash:comments>10</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/60464.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Even More SQLPrompt Goodness</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2006/07/28/10883.aspx</link>
            <description>If you want to read more about the product and the upcoming changes, check out &lt;A href="http://www.red-gate.com/MessageBoard/viewforum.php?f=44"&gt;Red-Gate's forum for SQLPrompt&lt;/A&gt;.&amp;nbsp; It includes a special price offer:&amp;nbsp; &lt;STRONG&gt;$99 introductory offer for pre-orders&lt;/STRONG&gt;.&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/10883.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2006/07/28/10883.aspx</guid>
            <pubDate>Fri, 28 Jul 2006 15:07:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2006/07/28/10883.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/10883.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SQLPrompt Revisited</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2006/07/27/10866.aspx</link>
            <description>&lt;P&gt;&lt;FONT face=Verdana&gt;A couple of months ago, I wrote a quick &lt;/FONT&gt;&lt;A href="http://weblogs.sqlteam.com/markc/archive/2006/05/24/9981.aspx"&gt;&lt;FONT face=Verdana&gt;post about SQLPrompt&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana&gt; which had been purchased by &lt;/FONT&gt;&lt;A href="http://www.red-gate.com/"&gt;&lt;FONT face=Verdana&gt;Red-Gate Software&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Verdana&gt;.&amp;nbsp; I have been using it since then and it really has proven to be a handy tool.&amp;nbsp; Of course, like any &lt;STRONG&gt;free&lt;/STRONG&gt; tool, there are a couple of things I'd like to see changed, and I fully expected taht Red-Gate already had plans for making those changes when they re-release it as a paid tool (called SPLPrompt 3).&amp;nbsp; I have now had the chance to communicate via email with a couple of representatives from Red-Gate and can tell you a little more about the upcoming release.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;Probably the most useful feature of SQLPrompt is when writing JOIN statements, it pops up a list of ON clauses for the tables in your query.&amp;nbsp; If your table names are aliased, it uses the alias.&amp;nbsp; If you have Foreign Keys defined between the tables, it recommends those.&amp;nbsp; There is an option where you can also have it recommend fields that are named the same, whether there is a Foreign Key relationship or not.&amp;nbsp; This makes writing JOINs pretty darn quick.&amp;nbsp; Sometimes it would recommend several more options than you were looking for, but hey, better to have too many than not enough in this case.&amp;nbsp; The free tool also stumbled occasionally in handling&amp;nbsp;joins across databases on the same server.&amp;nbsp; Among other things, I have been told that they have improved the JOIN support, so I look forward to checking out the new version.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;I believe it is safe to post the summary list of improvements that Red-Gate communicated to me, which is:&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;Significantly increased speed and accuracy&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;Keystrokes much closer to Visual Studio&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;Greater ease of use&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;Fewer prompts for authentication&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;New tables recognized as you create them&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana&gt;Improved JOIN support&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;They currently expect the price of SQLPrompt 3 to be $195 per user when it is released in September.&amp;nbsp; I do not yet have any information on group or site license discounts.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;So, you still have a month to check out the free edition and budget for the new release.&amp;nbsp; Happy coding!&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/10866.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2006/07/27/10866.aspx</guid>
            <pubDate>Thu, 27 Jul 2006 15:42:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2006/07/27/10866.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/10866.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SQLPrompt - Intellisense in Query Analyzer - Initial Review</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2006/05/24/9981.aspx</link>
            <description>&lt;P&gt;I just downloaded and installed the free tool &lt;A href="http://www.red-gate.com/products/SQL_Prompt/index.htm"&gt;SQLPrompt&lt;/A&gt;, now from Red-Gate Software, and I'm really liking it.&amp;nbsp; It provides Intellisense or statement-completion features in SQL Query Analyzer, SQL Server Management Studio, Visual Studio, and other development tools.&amp;nbsp; For example, it not only pops up a list of fields after you type a table name followed by period, but it will also lookup relationships and give you options for your JOIN ON statement (and of course a whole lot more).&amp;nbsp; So, even if you are working in a small database where you already know all the fields and relationships, it will save you time typing.&lt;/P&gt;
&lt;P&gt;It also provides snippet shortcuts, for example one that it comes with already setup is that you can type in &lt;EM&gt;ssf&lt;/EM&gt; and hit TAB and it replaces it with the syntax &lt;EM&gt;SELECT * FROM&lt;/EM&gt;.&amp;nbsp; You can build your own snippets.&amp;nbsp; Oh sure, I know that SQL Management Studio already has that ability, but if you still do any work in SQL 7 or 2000 in QA, it's a nice addition.&lt;/P&gt;
&lt;P&gt;For now, until September 1, 2006, this tool is free.&amp;nbsp; If I understand the scenario, Red-Gate bought this tool and plans to enhance it, so I would expect there to be a charge for it after September 1, or perhaps they will just roll it into one of their bundles.&amp;nbsp; So, if you're interested, get it now!&lt;/P&gt;&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/9981.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2006/05/24/9981.aspx</guid>
            <pubDate>Wed, 24 May 2006 20:53:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2006/05/24/9981.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/9981.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Top 10 Blog Design Mistakes</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2006/01/08/8742.aspx</link>
            <description>&lt;P&gt;Jakob Nielsen, a renowned web design and usability expert, has come up with the &lt;A href="http://www.useit.com/alertbox/weblogs.html"&gt;Top 10 Design Mistakes&lt;/A&gt; for Weblog Usability.&amp;nbsp; You might think, from the title, that there is nothing you can do because you did not &lt;STRONG&gt;&lt;EM&gt;design&lt;/EM&gt;&lt;/STRONG&gt; your weblog, you are using someone else's software.&amp;nbsp; But in reality, they are all focused on things that the blog writer does or does not do, and are great things to keep in mind.&amp;nbsp; I especially like this one:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT size=4&gt;9. Forgetting That You Write for Your Future Boss&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/8742.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2006/01/08/8742.aspx</guid>
            <pubDate>Mon, 09 Jan 2006 06:53:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2006/01/08/8742.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/8742.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How NOT to Select Records</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2004/09/01/1997.aspx</link>
            <description>&lt;P&gt;From &lt;A href="http://thedailywtf.com/archive/2004/09/01/1511.aspx"&gt;The Daily WTF&lt;/A&gt;... How &lt;STRONG&gt;&lt;FONT color=#ff0000&gt;NOT&lt;/FONT&gt;&lt;/STRONG&gt; to SELECT records in your database.&lt;/P&gt;
&lt;P&gt;Apparently in his version of SQL Server, WHERE clauses only work on Temp tables.&lt;/P&gt;&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/1997.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2004/09/01/1997.aspx</guid>
            <pubDate>Wed, 01 Sep 2004 20:19:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2004/09/01/1997.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/1997.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Separate Your Singular From Your Plurals</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2004/08/13/1916.aspx</link>
            <description>&lt;P&gt;This is a real pet peeve of mine, and I know some of you consider what I'm about to rant about to be some form of &amp;#8220;best practices&amp;#8221; or that &amp;#8220;it just makes sense&amp;#8221;, but I don't like it and I wish you'd stop.&amp;nbsp; Here's the issue:&amp;nbsp; Singular vs. Plural names of objects&amp;nbsp;and variables.&amp;nbsp; Everyone will probably agree that have &lt;STRONG&gt;a&lt;/STRONG&gt; naming convention for your database objects is important.&amp;nbsp; And most developers agree that having meaningful variable names is important too.&amp;nbsp; Now, do everyone a favor and &lt;STRONG&gt;&lt;FONT color=#ff0000&gt;stop&lt;/FONT&gt;&lt;/STRONG&gt; mixing singulars and plurals together!&lt;/P&gt;
&lt;P&gt;For database objects, just decide whether they are going to be singular or plural and stick with it.&amp;nbsp; It is &lt;STRONG&gt;really&lt;/STRONG&gt; annoying to have to remember that the table names are Employ&lt;FONT color=#ff0000&gt;&lt;STRONG&gt;er&lt;/STRONG&gt;&lt;/FONT&gt; and Custom&lt;FONT color=#ff0000&gt;&lt;STRONG&gt;ers&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;.&amp;nbsp; Or was that Employ&lt;STRONG&gt;&lt;FONT color=#ff0000&gt;ers&lt;/FONT&gt;&lt;/STRONG&gt; and Custom&lt;STRONG&gt;&lt;FONT color=#ff0000&gt;er&lt;/FONT&gt;&lt;/STRONG&gt;?&amp;nbsp; And Microsoft is guilty of this too!&amp;nbsp; Have you looked at the Northwind and Pubs databases?&amp;nbsp; Northwind:&amp;nbsp;&amp;nbsp;shipper&lt;STRONG&gt;s&lt;/STRONG&gt; and supplier&lt;STRONG&gt;s&lt;/STRONG&gt; but region;&amp;nbsp;Pubs:&amp;nbsp; author&lt;STRONG&gt;s&lt;/STRONG&gt;, discount&lt;STRONG&gt;s&lt;/STRONG&gt;, job&lt;STRONG&gt;s&lt;/STRONG&gt;, and publisher&lt;STRONG&gt;s&lt;/STRONG&gt;, but employee, roysched, and titleauthor.&amp;nbsp; My position is that not every tablename will make sense as a plural, but everything can make sense as singular, so I only use singular names.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;I know some of you will argue that&amp;nbsp;a table is a collection of records and so the table would be properly known as Employee&lt;STRONG&gt;s&lt;/STRONG&gt; and one record is &lt;STRONG&gt;an&lt;/STRONG&gt; Employee, but I just don't buy it.&amp;nbsp; It's easier to adapt to knowing that everything will be singular.&amp;nbsp; If you want plurals, then talk about the Employee &lt;STRONG&gt;records&lt;/STRONG&gt; that are found in the Employee table.&amp;nbsp; Or, heck, talk about Employee&lt;STRONG&gt;s&lt;/STRONG&gt; all you want, but everyone knows that when they have to code, the real object name is Employee.&lt;/P&gt;
&lt;P&gt;And programmers are just as bad with their variable names.&amp;nbsp; It drives me crazy to see something like &lt;EM&gt;For Each Employee in Employees...&lt;/EM&gt; or some such nonsense.&amp;nbsp; First, it makes it hard to read all the other lines where you have to distinquish between whether the single or plural is being acted upon.&amp;nbsp; And if you're&amp;nbsp;editing, it's really easy to overlook&amp;nbsp;whether the&amp;nbsp;&amp;#8220;s&amp;#8221; was there or not or&amp;nbsp;should have been.&amp;nbsp; Second it makes all communication difficult.&amp;nbsp; It is too easy to say or type the singular when you meant the plural or vice-versa.&amp;nbsp; Try using something like EmployeeList for the plural, or ThisEmployee for the singular.&amp;nbsp; Just don't make them identical except for one letter!&lt;/P&gt;
&lt;P&gt;I actually ran into this problem today talking about two different tables in the same database.&amp;nbsp; They were named almost identically, except to really irritate us, not only was there a mix of singular and plural, but&amp;nbsp;somebody used an abbreviation for one of them.&amp;nbsp; So, for example, assume that the table names were &lt;STRONG&gt;Letter&lt;/STRONG&gt; and &lt;STRONG&gt;Ltrs&lt;/STRONG&gt;.&amp;nbsp; They are related but contain very different information.&amp;nbsp; Now, imagine having a long-distance phone conversation with someone explaing that they need to make a change to the &amp;#8220;letters&amp;#8221; table.&amp;nbsp; Which one am I talking about?&amp;nbsp; Did I mistakenly add an &amp;#8220;s&amp;#8221; when I am talking about the Letter table?&amp;nbsp; Or am I trying to pronounce Ltrs without saying L-T-R-S?&lt;/P&gt;
&lt;P&gt;Save yourself the headache and money.&amp;nbsp;&amp;nbsp;Remember I bill by the hour, and if it takes an extra 10 minutes per day for us to go through the &amp;#8220;Do you mean the X or Y table?&amp;#8221; or &amp;#8220;Oh! I thought you meant X not Y.&amp;#8221; then that's nearly an extra hour per week that you are paying me just to clarify our communication because somebody used a bad naming convention.&amp;nbsp; Over the course of a year-long contract, that's 6 full days' worth of work that you paid for.&lt;/P&gt;&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/1916.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2004/08/13/1916.aspx</guid>
            <pubDate>Sat, 14 Aug 2004 06:03:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2004/08/13/1916.aspx#feedback</comments>
            <slash:comments>8</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/1916.aspx</wfw:commentRss>
        </item>
        <item>
            <title>What Language do you THINK in?</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2004/06/24/1669.aspx</link>
            <description>&lt;P&gt;A &lt;A href="http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=35863"&gt;question on SQLTeam&lt;/A&gt; a few weeks ago got me thinking about the idea of what language you &lt;STRONG&gt;THINK&lt;/STRONG&gt; in.&amp;nbsp; Do you remember the movie &lt;A href="http://www.imdb.com/title/tt0083943/"&gt;Firefox&lt;/A&gt;?&amp;nbsp; (Okay, that came out in 1982, before some of you were even born, but at the time I was a Clint Eastwood fan and into military aircraft, so back off!)&amp;nbsp; The key to the movie is that the jet (codenamed Firefox) has a neural connection and the pilot controls things like firing armament by &lt;STRONG&gt;thinking&lt;/STRONG&gt; the command.&amp;nbsp; Of course,&amp;nbsp;it being the 1980s, the bad guys we were stealing the plane from were the Russians (or probably more accurately Soviet Union) so Clint had to THINK in Russian.&lt;/P&gt;
&lt;P&gt;Okay, maybe you don't like that example, so let's talk about learning any foreign language.&amp;nbsp; You know you're truly fluent when you can think in that language instead of thinking in your native language and translating.&amp;nbsp; You may be able to translate on the fly pretty fast, but you're nowhere near as efficient as someone who thinks in that language.&lt;/P&gt;
&lt;P&gt;So when you're building systems, what language do you think in?&amp;nbsp; Thinking in Access SQL is different from thinking in SQL Server T-SQL and both of those are very different from thinking in Oracle.&amp;nbsp; And the differences are even greater when you're talking about stored procedures instead of ad-hoc query syntax.&amp;nbsp; Another contrast we see on &lt;A href="http://www.sqlteam.com"&gt;SQLTeam&lt;/A&gt; a lot is people who think in procedural languages like VB or C# versus those who think in set-based languages like SQL.&amp;nbsp; You can tell what your thinking language is by looking at your initial thoughts on how to tackle a problem.&amp;nbsp; A good friend and client of mine, who is very smart technically, tends to think procedurally.&amp;nbsp; I&amp;nbsp;can think procedurally, but I've also learned to think set-based.&amp;nbsp;&amp;nbsp;The difference&amp;nbsp;often comes out when we are talking about various approaches to a problem.&amp;nbsp; For example, his idea might be to extract a set of&amp;nbsp;data and iterate through it categorizing and perhaps performing math; whereas my approach would be to see if we can craft a single SELECT statement with the right grouping and aggregate functions to have the database engine do all the hard work for us more efficiently.&amp;nbsp; My approach works better when you can use a set-based language like SQL.&amp;nbsp; His works better on some of the legacy systems we deal with that just don't support the syntax I would need.&amp;nbsp; But it's interesting to see what causes us to come at the same problem with two very different solutions, and that being whichever language we are thinking in.&lt;/P&gt;
&lt;P&gt;As for the question on SQLTeam...you'll notice that the person is essentially asking for a translation from Oracle, the language he's thinking in, to SQL Server syntax, but the recommended answers are to scrap that approach and instead learn to think in SQL Server.&lt;/P&gt;
&lt;P&gt;So, what language do &lt;STRONG&gt;you&lt;/STRONG&gt; think in?&amp;nbsp; Is it the same one that you're currently being paid to use?&amp;nbsp; If not, you are not as efficient as you could be.&amp;nbsp; And your code may be horribly inefficient, too.&lt;/P&gt;&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/1669.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2004/06/24/1669.aspx</guid>
            <pubDate>Fri, 25 Jun 2004 06:39:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2004/06/24/1669.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/1669.aspx</wfw:commentRss>
        </item>
        <item>
            <title>How Many Test/QA Instances do you Need?</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2004/06/02/1482.aspx</link>
            <description>&lt;P&gt;A while back, I blogged about having &lt;A href="http://weblogs.sqlteam.com/markc/archive/2004/02/26/988.aspx"&gt;separate dev, test/QA, and production environments&lt;/A&gt;.&amp;nbsp; Recently, I was discussing with one of my clients the fact that they really needed &lt;STRONG&gt;more than one&lt;/STRONG&gt; test/QA environment because they needed specific scenarios in their data to test the functionality of a broad spectrum of code paths.&amp;nbsp; But they also needed a large volume of data in order to do some performance testing.&amp;nbsp; And you could argue that these two different raison d'etre of the test systems would be better served with separate instances.&lt;/P&gt;
&lt;P&gt;So this got me thinking about just how many different test or QA instances do you need or would you want in an ideal world.&amp;nbsp; Here are some thoughts about different types of testing:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Unit Tests&lt;/STRONG&gt;:&amp;nbsp; In many shops this is done by the developer to make sure that their code is doing what's expected, at least to pass the 80/20 rule (i.e. it works on the common&amp;nbsp; or &amp;#8220;normal&amp;#8220; data sets).&amp;nbsp; Small data set is fine here.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Functionality&amp;nbsp;QA&amp;nbsp;Tests&lt;/STRONG&gt;:&amp;nbsp; These verify that the Unit Tests passed, and expand to include the &amp;#8220;edge cases&amp;#8220; (the 20% of the scenarios that take up 80% of your time).&amp;nbsp; Small data sets are fine, with the focus being on a broad spectrum of data scenarios.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Integration Testing&lt;/STRONG&gt;:&amp;nbsp; Do all the parts (units) which are often written by different people fit together properly?&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Performance / Volume Tests&lt;/STRONG&gt;:&amp;nbsp; Ideally, an exact copy of your production environment to really know how long something will take.&amp;nbsp; In practice, there is probably some smaller percentage that would allow you to give a statistically significant forecast.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Bug replication, testing,&amp;nbsp;and analysis&lt;/STRONG&gt;:&amp;nbsp; Again, ideally and exact copy of your production environment so you can ultimately test your theory on a copy of the real data that had the original problem.&amp;nbsp; Probably want this on a delayed-update such as refreshed nightly so you have time to catch the original data condition before the bug gets replicated into your test system.&amp;nbsp; Also could be built from backups on an as-needed basis.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Staging&lt;/STRONG&gt;:&amp;nbsp; Test your build and deployment process.&amp;nbsp; Needs to match production in terms of code and schema versions.&amp;nbsp; Also needs broad enough variety of data to touch all components at least once.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Bug-fix / Minor Release Testing&lt;/STRONG&gt;:&amp;nbsp; May be same as Staging, but the emphasis is on making sure no new major version release code is included.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Multiple Supported Versions Testing&lt;/STRONG&gt;:&amp;nbsp; If you support multiple versions of your product for clients, then you'll probably want to test bugs reported to find out which versions are affected.&amp;nbsp; If your latest version is 5.0, and a client running version 3.7 reports a bug, you want to know if it can be fixed by uprading the client to the latest version, or if everyone is facing the same problem.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Any others that come to mind for you?&amp;nbsp; Add them in the comments section.&lt;/P&gt;&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/1482.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2004/06/02/1482.aspx</guid>
            <pubDate>Thu, 03 Jun 2004 06:56:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2004/06/02/1482.aspx#feedback</comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/1482.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Scripts and Source Control - 102</title>
            <link>http://weblogs.sqlteam.com/markc/archive/2004/03/31/1160.aspx</link>
            <description>&lt;P&gt;In the comments section of my &lt;A href="http://weblogs.sqlteam.com/markc/archive/2003/10/21/343.aspx"&gt;SCRIPT IT&lt;/A&gt; post, Lisa asked a couple of questions for clarification.&amp;nbsp; These were a good reminder to me that some of the things that I just take for granted these days are actually very new concepts to others who haven't had the same experience.&amp;nbsp; So rather than just post a reply in comments, I thought it'd be worth a post unto its own.&amp;nbsp; Lisa's questions are in summarized&amp;nbsp;italics, with my responses following.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;Q1)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;EM&gt; You stated: "Often in EM there is an option to 'Script Changes'&amp;#8221;... I don't see any "Script Changes" in the BOL when I did a search. However, I did a search in the index of BOL and I find this: "script generating"...GREAT. However, when I open up the sql file, I was surprised by the amount of the code that is generated. I mean, there are about 60 lines of code!?!??!??! So far, I only created 1 db called, "TestingDB". I thought for a simple db, it should only a few line of commands.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;A1)&lt;/FONT&gt;&lt;/STRONG&gt; You found the option to generate scripts based on the current database settings.&amp;nbsp; This is a good way to get an intial snapshot in script form of your database.&amp;nbsp; As you have seen, there are many different options that will get scripted in order to have a script that would rebuild your database &lt;STRONG&gt;exactly&lt;/STRONG&gt; the way it is now.&amp;nbsp; Many of those options are default settings and many people don't bother to keep them in their scripts, but the script generator produces everything it can.&lt;/P&gt;
&lt;P&gt;Where I was talking about scripting the &lt;STRONG&gt;&lt;FONT color=#ff0000&gt;changes&lt;/FONT&gt;&lt;/STRONG&gt;, I meant, for example, changing the code in a stored procedure, or changing a table definition.&amp;nbsp;&amp;nbsp;Here's an example:&amp;nbsp; Open Enterprise Manager, open the &lt;STRONG&gt;pubs&lt;/STRONG&gt; database, click on tables, right-click authors and choose Design Table.&amp;nbsp; You are now in the table definition grid.&amp;nbsp; Change the length of column au_lname from 40 to 50.&amp;nbsp; Now, &lt;STRONG&gt;BEFORE YOU SAVE&lt;/STRONG&gt; the change you just made, on the toolbar there is a button that looks like a small disk with a scroll behind it (should be the third button from the left).&amp;nbsp; That is the "Save Change Script" button.&amp;nbsp; If you click it, it will generate a script in a window that represents the change you just made.&amp;nbsp; Then you can save that to a file.&amp;nbsp; But remember that here, too, the generator will provide a lot of standard default settings in the script and it also may not produce the most efficient way of making the change.&amp;nbsp; Because it's an automated process, it follows certain rules in order to generate a script that definitely will produce the change you have just made, but there may be other more efficient ways of achieving the same result.&amp;nbsp; As you gain more experience with different SQL statements, and since you can analyze the table and your needs, you may come up with shorter methods than what the generator produces.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;Q2)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;EM&gt; You stated: "You can (and should) save your script files (usually ending with a .sql extension) into some form of source control (Visual Source Safe, Concurrent Versioning System, etc.). " &lt;BR&gt;&amp;nbsp;- What is the benefit of saving .sql script into VSS or CVS? &lt;BR&gt;&amp;nbsp;- Do I need a special softwares to open these files? &lt;BR&gt;&lt;BR&gt;You also stated: "This allows you to know exactly what changes have been made, and if you ever need to &amp;#8220;roll back&amp;#8220; you have a history of changes." I understand what you are saying but it is hard for me to visualize without real example.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#0000ff&gt;A2)&lt;/FONT&gt;&lt;/STRONG&gt;&amp;nbsp; The .sql files are just plain text so they can be opened by any editor, including Notepad.&amp;nbsp; Some people like to associate the .sql extension with Query Analyzer so if they double-click the file in Windows Explorer it opens with that.&amp;nbsp; Personally, I don't want the overhead of opening QA when all I want is to do a quick view of the text file, so I use a&amp;nbsp;simple editor like Notepad for quick reading.&amp;nbsp; But I use QA for real editing because it has color formatting and I can execute tests while I'm working.&lt;/P&gt;
&lt;P&gt;As far as the benefits of saving changes into source control, there are many.&amp;nbsp; One is that it's a central storage area, so you always know where to find your scripts.&amp;nbsp; Another is that it's a nice way to organize a history of copies of the file.&amp;nbsp; Source control will be able to show you not only the current version of your script, but also previous versions.&amp;nbsp; Most source control programs also let you do a "diff" which is a way of showing the differences between two versions.&amp;nbsp; This is very handy for answering questions like "Just exactly what changes were made the last time?"&amp;nbsp; I find this most useful when I'm working on scripts for stored procedures.&amp;nbsp; And you can check out an old copy of the script and execute it in order to "rollback".&amp;nbsp; For example, let's say you made changes to a stored procedure script, executed it in your database and saved (checked-in) the changes to your source control.&amp;nbsp; Later you discover that there is something wrong with the change you made.&amp;nbsp; Assuming that it is not significant enough to require restoring the database from backup, you could check-out the &lt;STRONG&gt;previous&lt;/STRONG&gt; version of the script and execute it, thus effectively rolling back (undoing)&amp;nbsp;the change you made.&amp;nbsp; Of course this all only works if you've been checking-in the changes to your script and thus producing a history of changes.&lt;/P&gt;
&lt;P&gt;Some source control systems automatically check in any changes you made every time you save or execute.&amp;nbsp; I don't like this approach.&amp;nbsp; I don't want the previous version listed in history to be my previous typo or some unit-test run with part of the code commented out for testing purposes.&amp;nbsp; I want it to be truly the last version that was believed by the developer to be a working version, so I want it to be a conscious act to check-in updated scripts.&lt;/P&gt;
&lt;P&gt;Hope that helps you Lisa, and all others who are coming in to this arena anew.&lt;/P&gt;&lt;img src="http://weblogs.sqlteam.com/markc/aggbug/1160.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>AjarnMark</dc:creator>
            <guid>http://weblogs.sqlteam.com/markc/archive/2004/03/31/1160.aspx</guid>
            <pubDate>Wed, 31 Mar 2004 16:42:00 GMT</pubDate>
            <comments>http://weblogs.sqlteam.com/markc/archive/2004/03/31/1160.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://weblogs.sqlteam.com/markc/comments/commentRss/1160.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>