<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results matching tags 'Best Practices' and 'Automation'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=Best+Practices,Automation&amp;orTags=0</link><description>Search results matching tags 'Best Practices' and 'Automation'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>New White Paper: SQL Server Extended Events and Notifications</title><link>http://sqlblog.com/blogs/kevin_kline/archive/2012/04/25/new-white-paper-sql-server-extended-events-and-notifications.aspx</link><pubDate>Wed, 25 Apr 2012 13:13:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:42932</guid><dc:creator>KKline</dc:creator><description>&lt;p&gt;SQL Server comes with a wide array of tools for monitoring your environment. There are logs and traces that provide information when errors occur, but these are often used passively to react to events that have already occurred. &amp;nbsp;There's PerfMon, and Profiler, and loads of Dynamic Management Views to check. &amp;nbsp;But where to look?&lt;/p&gt;&lt;p&gt;As database administrators (DBA), we need to monitor our environments proactively and create solutions as issues arise. In this white paper, we will look at a couple technologies – event notifications and extended events – that can help you achieve these goals. With these two features, we’ll look at the error log and deadlocks, and demonstrate how you can get relevant information delivered as it occurs. We’ll also look at ways that run-time errors can be captured and used to help reduce the amount of time required to investigate issues.&lt;/p&gt;&lt;p&gt;This white paper, written by SQL Server MVP Jason Strate (&lt;a title="Jason Strate's SQL Server Blog" href="http://www.jasonstrate.com/"&gt;blog&lt;/a&gt;&amp;nbsp;|&amp;nbsp;&lt;a title="Jason Strate's Twitter Feed" href="http://twitter.com/stratesql"&gt;twitter&lt;/a&gt;), is a free download &lt;em&gt;but requires a registration&lt;/em&gt;.&amp;nbsp; &lt;a title="Microsoft SQL Server Extended Events White Paper" href="http://www.quest.com/whitepaper/how-to-use-sql-servers-extended-events-and-notifications816315.aspx"&gt;Download the Extended Events white paper here&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;And, as always, I enjoy your feedback. &amp;nbsp;Thanks!&lt;/p&gt;&lt;p&gt;-Kev&lt;/p&gt;&lt;p&gt;&amp;nbsp;Follow me on&amp;nbsp;&lt;a title="Kevin Kline's Twitter Feed" href="http://twitter.com/kekline"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;</description></item><item><title>Pain of the Week/Expert's Perspective: Performance Tuning for Backups and Restores</title><link>http://sqlblog.com/blogs/kevin_kline/archive/2011/06/27/pain-of-the-week-expert-s-perspective-performance-tuning-for-backups-and-restores.aspx</link><pubDate>Mon, 27 Jun 2011 14:39:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36482</guid><dc:creator>KKline</dc:creator><description>&lt;p&gt;First off - the Pain of the Week webcast series has been renamed.&amp;nbsp; It's now known as &lt;em&gt;The Expert's Perspective&lt;/em&gt;.&amp;nbsp;
 Please join us for future webcasts and, if you're interested in 
speaking, drop me a note to see if we can get you on the roster!&lt;br&gt;&lt;/p&gt;&lt;p&gt;The
 bigger your databases get, the longer backups take. That doesn't really
 seem like a huge problem — until disaster strikes and you need to 
restore your databases as fast as possible.&lt;/p&gt;
&lt;p&gt;Join my buddy Brent Ozar (&lt;a href="http://brentozar.com/" title="One of the few, the proud, the MCMs" target="_blank"&gt;blog&lt;/a&gt; |&amp;nbsp;&lt;a href="http://twitter.com/brento" title="Tro-lo-lo with BrentO" target="_blank"&gt;twitter&lt;/a&gt;),
 a Microsoft Certified Master of SQL Server and good friend, as he 
reveals ways to make these critically important maintenance tasks run 
faster.&lt;/p&gt;
&lt;p&gt;You'll discover:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Why Instant File Initialization is so important for restores&lt;/li&gt;&lt;li&gt;How to use DMVs to check restore progress&lt;/li&gt;&lt;li&gt;How to find the bottleneck while you're backing up or restoring data&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Watch the recorded presentation at &lt;a href="http://www.quest.com/events/ListDetails.aspx?ContentID=13358"&gt;http://www.quest.com/events/ListDetails.aspx?ContentID=13358&lt;/a&gt;!&lt;/p&gt;&lt;p&gt;Enjoy!&lt;/p&gt;&lt;p&gt;-Kev&lt;/p&gt;
&lt;div&gt;&lt;span style="font-family:'Times New Roman';"&gt; &lt;a href="http://twitter.com/kekline" title="C'mon. You know you want to!" target="_blank"&gt;Follow me on Twitter at kekline&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:'Times New Roman';"&gt; More content at&amp;nbsp;&lt;a href="http://kevinekline.com/"&gt;http://KevinEKline.com&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;</description></item><item><title>Database Maintenance Scripting Done Right</title><link>http://sqlblog.com/blogs/kevin_kline/archive/2011/02/18/database-maintenance-scripting-done-right.aspx</link><pubDate>Fri, 18 Feb 2011 13:16:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:33607</guid><dc:creator>KKline</dc:creator><description>&lt;br&gt;I first wrote about useful database maintenance scripts on my&lt;a href="http://sqlblog.com/blogs/kevin_kline/archive/2008/03/26/more-sql-server-automation-scripts.aspx" title="Mad skillz in Mad scriptz" target="_blank"&gt; SQLBlog account&lt;/a&gt; way back in 2008.  Hmmm - now that I think about it, I first wrote about my own useful database maintenance scripts in a journal called SQL Server Professional back in the mid-1990's on SQL Server v6.5 or some such.  But I digress...

&lt;a href="http://KevinEKline.com"&gt;&lt;img src="http://www.binbin.net/photos/everythingplay/mov/movie-script-note-book.jpg" title="Script" alt="" height="247" width="247"&gt;&lt;/a&gt;

Anyway, I pointed out a couple useful sites where you could get some good scripts that would take care of preventative maintenance on your SQL Server, such as index defragmentation, updating statistics, and so forth.  One of the script kits came directly from Microsoft's internal database management team.  But, alas, they haven't published any updates in quite a while.  On the other hand, the other set of scripts came from Ola Hallengren, who has done a great job keeping his scripts up to date.

Recently, Ola added support for updating column statistics, both in a generalized update and also updates for only those columns whose statistics have been modified.  He's added some other goodies to the latest release, which you can read about here, &lt;a href="http://ola.hallengren.com/Versions.html"&gt;http://ola.hallengren.com/Versions.html&lt;/a&gt; for all details.

In addition, I'd like to remind you of the white paper I wrote a while back called &lt;a href="http://www.quest.com/documents/landing.aspx?id=10931" title="Free, but registration is required" target="_blank"&gt;&lt;em&gt;Automating DBA Processes&lt;/em&gt;&lt;/a&gt;, which covers many aspects of database automation and cherry picks some of the best practices from many different thought leaders, such as Ola, Michelle Ufford &lt;a href="http://sqlfool.com/" target="_blank"&gt;(&lt;/a&gt;&lt;a href="http://sqlfool.com/"&gt;blog&lt;/a&gt; | @&lt;a href="http://twitter.com/sqlfool"&gt;sqlfool&lt;/a&gt;) who will be speaking at the &lt;a href="http://www.sqlpass.org/24hours/Spring2011/default.aspx" title="Celebrating Women in Technology with an all-female speaker line up!" target="_blank"&gt;24HOP &lt;/a&gt;soon, and Allen White (&lt;a href="http://sqlblog.com/blogs/allen_white/archive/tags/PowerShell/default.aspx" target="_blank"&gt;blog&lt;/a&gt; | &lt;a href="http://twitter.com/sqlrunr"&gt;twitter&lt;/a&gt;).</description></item><item><title>Scripting for the out-of-band attention</title><link>http://sqlblog.com/blogs/linchi_shea/archive/2010/11/20/scripting-for-the-out-of-band-attention.aspx</link><pubDate>Sun, 21 Nov 2010 02:53:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:30846</guid><dc:creator>Linchi Shea</dc:creator><description>&lt;p&gt;I have written a lot of throw-away scripts, some of which were written to control the execution of a large number of SQL scripts. The logic of these control scripts is often simple, but their execution can last for a long time (e.g. hours). When writing this type of control scripts, people would generally give some thoughts to improve robustness in case things crap out unexpectedly in the middle of their running. &lt;/p&gt;&lt;p&gt;When a script is long running, chances are people may change their minds after the script has started running, and want to abort it.&amp;nbsp;I might be wrong, but it seems that not much explicit consideration is given to this change-of-mind scenario in scripting-related discussions.&lt;/p&gt;&lt;p&gt;True, if you have spent a lot of time making the control script and the controlled SQL scripts super robust to the extent that you can just Ctrl-C to abort their execution and expect things to be in a good enough state, good for you! But we are talking about throw-away scripts. As much as we want to make them super robust, it may not be cost effective to actually do so. Typically, a throw-away script is written to deal with a scenario that is sufficiently narrow and we know what craps we may have to deal with and/or how we can handle them if the script indeed aborts unexpectedly. However, that does not mean that we should just go ahead with Ctrl-C, well, unless you enjoy dealing with craps that may come out of Ctrl-C. It can be done better.&lt;/p&gt;&lt;p&gt;Let me give a specific example.&amp;nbsp;&lt;/p&gt;&lt;p&gt;Assume that you have data on some gadget items, orders, item stocks, fulfillments, and item returns, and for each month, you have a separate table for items, a separate table for orders, and so on. Since you need to&amp;nbsp;convert all these tables to different schema for an upgrade, you have prepared T-SQL conversion scripts, one for each table. If your data go back for many years, you have a lot of migration scripts to execute for the upgrade. Being a lazy database professional, you write a control script to loop through all the months, and then another loop to go through the tables for that month, executing their respective conversion scripts in these two nested loops.&lt;/p&gt;&lt;p&gt;Now, just when you have started running this control script, you may suddenly realize that maybe you should have divided the tables into several groups, and execute the conversion scripts for each group in parallel. So you want to stop the current execution, and re-arrange your script. Or you just want to stop the execution of the control script for whatever reason that you may fancy.&lt;/p&gt;&lt;p&gt;As said, you can hit Ctrl-C and hope for the best. Or you can give some thought to this requirement when writing your control script, and build the logic into your script so that it responds to external events and exits the script gracefully at a certain desirable point. This can be something extremely simple. For instance, in the control script for the above-mentioned conversion, I may add a simple check upon the entry into each loop to see whether a dummy file can be opened. If yes, the script continues; if not, the script exits. This gives me a means to tell the script,&amp;nbsp;out of band,&amp;nbsp;to abort by simply creating or deleting that dummy file. Alternatively, if you want to be fancier, you can have the script re-check a config file repeatedly at certain points of its execution. By changing the config value, you can alter the script behavior out of band dynamically. The point is that there are many simple ways to signal the control script out of band if you give this potential requirement a little bit of thought in advance.&lt;/p&gt;&lt;p&gt;If you are writing a serious piece of software, what I'm rambling about here goes without saying. Scripting is a different beast; you often have to trade off robustness for 'time-to-market'. I just wouldn't want to see you going overboard in the process, forgetting that a long-running script may behave much more gracefully if it's prepared to respond to the attention out-of-band.&lt;/p&gt;</description></item></channel></rss>