<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.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>Adam Machanic : monitoring, Scripts</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/monitoring/Scripts/default.aspx</link><description>Tags: monitoring, Scripts</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Who is Active? v9.57: Fast, Comprehensive DMV Collection - What's Really Happening on Your Server?</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2009/12/03/who-is-active-v9-57-fast-comprehensive-dmv-collection.aspx</link><pubDate>Thu, 03 Dec 2009 19:59:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:19489</guid><dc:creator>Adam Machanic</dc:creator><slash:comments>24</slash:comments><comments>http://www2.sqlblog.com/blogs/adam_machanic/comments/19489.aspx</comments><wfw:commentRss>http://www2.sqlblog.com/blogs/adam_machanic/commentrss.aspx?PostID=19489</wfw:commentRss><description>UPDATE, April 28 2011: Who is Active v9.57 is outdated. Please use v11.00 instead. Happy December, SQLblog readers! My gift to you, just in time for the holidays: The newest "official" release of your favorite SQL Server activity monitoring stored procedure...(&lt;a href="http://www2.sqlblog.com/blogs/adam_machanic/archive/2009/12/03/who-is-active-v9-57-fast-comprehensive-dmv-collection.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=19489" width="1" height="1"&gt;</description><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/DMVs/default.aspx">DMVs</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/monitoring/default.aspx">monitoring</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/Performance/default.aspx">Performance</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/who+is+active/default.aspx">who is active</category></item><item><title>Who is Active? v8.82 - Harder, Better, Faster, Stronger</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2009/08/20/who-is-active-v8-82-harder-better-faster-stronger.aspx</link><pubDate>Thu, 20 Aug 2009 15:03:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:16149</guid><dc:creator>Adam Machanic</dc:creator><slash:comments>13</slash:comments><comments>http://www2.sqlblog.com/blogs/adam_machanic/comments/16149.aspx</comments><wfw:commentRss>http://www2.sqlblog.com/blogs/adam_machanic/commentrss.aspx?PostID=16149</wfw:commentRss><description>I've had a lot of great feedback since my last "official" Who is Active? release-- v8.40, back in March --and since then I've made 42 distinct changes, bringing us all the way to v8.82. My versioning scheme is quite simple: one change, one increment,...(&lt;a href="http://www2.sqlblog.com/blogs/adam_machanic/archive/2009/08/20/who-is-active-v8-82-harder-better-faster-stronger.aspx"&gt;read more&lt;/a&gt;)&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=16149" width="1" height="1"&gt;</description><enclosure url="http://www2.sqlblog.com/blogs/adam_machanic/attachment/16149.ashx" length="17605" type="application/zip" /><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/DMVs/default.aspx">DMVs</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/monitoring/default.aspx">monitoring</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/who+is+active/default.aspx">who is active</category></item><item><title>Who is Active? v8.40 - Now With Delta Power!</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2009/03/30/who-is-active-v8-40-now-with-delta-power.aspx</link><pubDate>Mon, 30 Mar 2009 16:41:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:13006</guid><dc:creator>Adam Machanic</dc:creator><slash:comments>26</slash:comments><comments>http://www2.sqlblog.com/blogs/adam_machanic/comments/13006.aspx</comments><wfw:commentRss>http://www2.sqlblog.com/blogs/adam_machanic/commentrss.aspx?PostID=13006</wfw:commentRss><description>
&lt;p&gt;&lt;b style="font-size:200%;"&gt;NOTE: v8.40 is outdated at this time. Please try v9.57, &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2009/12/03/who-is-active-v9-57-fast-comprehensive-dmv-collection.aspx"&gt;which you can find here&lt;/a&gt;.&lt;/b&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;It has been only a month and a half since I posted the last version of Who is Active? (&lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2009/02/18/who-is-active-v7-30.aspx"&gt;v7.30&lt;/a&gt;),
but in that time I've made a huge number of changes, fixes, and
enhancements. &lt;a href="http://sqlblog.com/blogs/adam_machanic/attachment/13006.ashx"&gt;The new version, v8.40&lt;/a&gt;, is faster, more robust, and
includes a few exciting features. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/attachment/13006.ashx"&gt;&lt;b&gt;Click here to download Who is Active? v8.40&lt;/b&gt;&lt;/a&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Following is a list of some of the
things I've done with it, in no particular order, along with
descriptions where applicable.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Added a &lt;b&gt;collection interval&lt;/b&gt;
option, @DELTA_INTERVAL. This option causes the script to collect
numeric metrics -- such as reads, writes, and context switches --
twice. The script will wait between collections, based on the duration
passed into the parameter (in seconds). The script will then calculate
the differences (deltas), between the first and second collections, for
any requests that were active for each collection. These deltas will be
output in a new set of columns, reads_delta, writes_delta,
context_switches_delta, etc.&lt;/p&gt;

&lt;p&gt;For example, to use the default options and wait two seconds between collections, you would use the following:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EXEC sp_WhoIsActive @DELTA_INTERVAL = 2;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;If
you played with Who is Active? in the past you know that the script
outputs a lot of data in a lot of different columns. I started feeling
that the column list was getting unwieldy, so I implemented &lt;b&gt;dynamic column lists&lt;/b&gt;
as a fix. There are two changes here. First of all, the default column
list will only contain columns associated with those features you have
turned on. So for example, if you don't have @GET_LOCKS enabled, the
locks column won't appear.&lt;/p&gt;

&lt;p&gt;The second part of this fix is a new feature to make things even more dynamic: &lt;b&gt;custom column lists&lt;/b&gt;. I sent a slightly earlier test version to &lt;a href="http://blogs.msdn.com/jimmymay/"&gt;Jimmy May&lt;/a&gt;,
and his response was something along the lines of, "it's pretty good,
but I really don't like the column order." To make Jimmy happy, I
implemented the @OUTPUT_COLUMN_LIST option. To use this option, simply
pass in whatever columns you would like to see, in whatever order you
would like to see them, and the script will do the rest. Note that the
output will be the intersection of whatever options are enabled and
whatever columns are found in the list.&lt;/p&gt;

&lt;p&gt;Here's an example I've been using in my own work recently:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EXEC sp_WhoIsActive &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @OUTPUT_COLUMN_LIST = &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; '[login_name],[dd hh:mm:ss.mss],[sql_text],[reads],[writes],&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [context_switches],[physical_io],[wait_info],[blocking_session_id],&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [tempdb_writes],[tran_log_writes],[query_plan],[session_id]';&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Another feature I added that makes things a bit more dynamic and customizable is the &lt;b&gt;ability to sort the output&lt;/b&gt;
based on whatever column and direction you would like. Interested in
seeing the requests that are currently blocked? No need to scroll, just
ask for them to sort high:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;EXEC sp_WhoIsActive &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @SORT_COLUMN = '[blocking_session_id]',&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @SORT_COLUMN_DIRECTION = 'DESC';&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;While
viewing the results on the screen in SSMS is great, sometimes I like to
capture the results to a table for later analysis. So I added a few
features in this most recent version to support &lt;b&gt;automated collection&lt;/b&gt;. &lt;/p&gt;

&lt;p&gt;To
begin with, I realized that the default, nicely-formatted output of the
script, while great for on-screen viewing, isn't good if you want to do
your own analysis later. So I added a new option, @FORMAT_OUTPUT, that
lets you &lt;b&gt;control whether the output is or is not formatted&lt;/b&gt;. The default value for the parameter is 1, keeping with the previous behavior.&lt;/p&gt;

&lt;p&gt;I
also figured that if you want to do some later analysis it might be
nice to know what time period you're working with. So I added a column
called collection_time, which outputs a datetime instance representing
the &lt;b&gt;time that the script finished running&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;Taking things
one step further, I decided that with all of the dynamic column options
it would be a pain to put together a table matching the output schema
if you start playing with different settings. So I made things easy; no
need to figure out what the output looks like; &lt;b&gt;the script will write a CREATE TABLE statement for you&lt;/b&gt;. Simply enable the @RETURN_SCHEMA option and collect the output value from the @SCHEMA parameter.&lt;/p&gt;

&lt;p&gt;Finally,
due to nested INSERT/EXEC limitations, it's impossible to insert the
result into a table when calling the stored procedure. No worries, the
script will &lt;b&gt;insert its output into a table&lt;/b&gt; for you. Just tell it where to send the data, via the @DESTINATION_TABLE option.&lt;/p&gt;

&lt;p&gt;Here's
an example of asking for the unformatted output schema, creating a
destination table based on the current day, and collecting data 10
times, waiting 15 seconds between each collection:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;DECLARE @destination_table VARCHAR(4000);&lt;br&gt;SET @destination_table = 'WhoIsActive_' + CONVERT(VARCHAR, GETDATE(), 112);&lt;br&gt;&lt;br&gt;DECLARE @schema VARCHAR(4000);&lt;br&gt;EXEC sp_WhoIsActive&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @FORMAT_OUTPUT = 0,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @RETURN_SCHEMA = 1,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @SCHEMA = @schema OUTPUT;&lt;br&gt;&lt;br&gt;SET @schema = &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; REPLACE&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @schema, &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; '&amp;lt;table_name&amp;gt;', &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @destination_table&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br&gt;&lt;br&gt;EXEC(@schema);&lt;br&gt;&lt;br&gt;DECLARE @i INT;&lt;br&gt;SET @i = 0;&lt;br&gt;&lt;br&gt;WHILE @i &amp;lt; 10&lt;br&gt;BEGIN;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; EXEC sp_WhoIsActive&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @FORMAT_OUTPUT = 0,&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; @DESTINATION_TABLE = @destination_table;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @i = @i + 1;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WAITFOR DELAY '00:00:15'&lt;br&gt;END;&lt;br&gt;GO&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;One of the key reasons I created the &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2007/12/31/a-gift-of-script-for-2008-who-s-active-what-are-they-doing-and-who-is-blocked.aspx"&gt;original version&lt;/a&gt; of Who is Active? was to help &lt;b&gt;identify blocked and blocking SPIDs&lt;/b&gt;. And I thought it worked pretty well for that purpose until recently, when I discovered that &lt;a href="http://sqlblog.com/blogs/aaron_bertrand/archive/2009/03/21/six-reasons-you-should-be-nervous-about-parallelism.aspx"&gt;sys.dm_exec_requests fails to properly identify blocking when queries go parallel&lt;/a&gt;. Oops. Fixed in the new version; it now uses the waiting tasks DMV for this purpose, instead of the requests DMV.&lt;/p&gt;

&lt;p&gt;As
part of this process I discovered that the joins to the tasks DMVs were
slightly flawed in v7.30, so I fixed them up. And I was able to play
some games to improve performance--enough that I decided to eliminate
the @TASK_INFO option, making this the default behavior. This means
that you'll always get &lt;b&gt;correct blocker identification&lt;/b&gt; from Who
is Active? v.8.40, along with a few bonus task-based metrics including
physical I/O stats and the number of context switches.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Interested in information about transactions? So are most DBAs, which is why I &lt;b&gt;promoted the transaction start time&lt;/b&gt;, which was previously embedded in the tran_log_writes column, &lt;b&gt;to a top-level column&lt;/b&gt;
of its own. This will still populate only with transactions that have
actually done a write, but from what my testers tell me this is okay
behavior. Let me know if you disagree. While I was in there I played
even more performance games, and greatly improved the speed of the
query when the @GET_TRANSACTION_INFO option is enabled.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;A few smaller fixes are also worth mentioning here. First of all, I tested the script against a &lt;b&gt;case-sensitive instance&lt;/b&gt;, and fixed a few issues there. So it should work for you no matter what collation you're using. Second, thanks to &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2009/03/15/the-grouped-string-concatenation-challenge-is-closed.aspx#comments"&gt;a discussion I had with Roman Nowak&lt;/a&gt;, I was able to finally &lt;b&gt;solve the entitization problem&lt;/b&gt; that plagued the "clickable" query output produced by the script. Third, I put on my security hat and added some code to &lt;b&gt;verify input arguments&lt;/b&gt;, as well as did a review of all of the dynamic SQL used by the script to make sure that &lt;b&gt;it is not injectable&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;Thank
you to everyone who sent me feedback and/or feature requests! If you
have an idea for th script, please make sure to send it my way. I have
quite a bit of momentum at the moment and want to keep going and see
just how far I can take this thing. &lt;b&gt;I can only do this with your help&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;Enjoy! &lt;/p&gt;

&lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/attachment/13006.ashx"&gt;&lt;b&gt;Click here to download Who is Active? v8.40&lt;/b&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=13006" width="1" height="1"&gt;</description><enclosure url="http://www2.sqlblog.com/blogs/adam_machanic/attachment/13006.ashx" length="14867" type="application/zip" /><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/DMVs/default.aspx">DMVs</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/monitoring/default.aspx">monitoring</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/who+is+active/default.aspx">who is active</category></item><item><title>Who is Active? v7.30</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2009/02/18/who-is-active-v7-30.aspx</link><pubDate>Wed, 18 Feb 2009 15:34:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11971</guid><dc:creator>Adam Machanic</dc:creator><slash:comments>5</slash:comments><comments>http://www2.sqlblog.com/blogs/adam_machanic/comments/11971.aspx</comments><wfw:commentRss>http://www2.sqlblog.com/blogs/adam_machanic/commentrss.aspx?PostID=11971</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/attachment/11971.ashx"&gt;Who is Active?&lt;/a&gt; is a comprehensive DMV-based monitoring script, designed to tell you at a glance what processes are active on your SQL Server and what they're up to. It has a number of optional features so that you can get results quickly, or monitor deeply, depending on your needs when you happen to be using the script. Today I'm happy to present a new version, v7.30, which includes a few bug fixes an a new feature.&lt;/p&gt;&lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/attachment/11971.ashx"&gt;&lt;b&gt;Click here to download Who is Active? v7.30&lt;/b&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Now that I've covered that (for people who haven't been paying attention to this blog as of late), a bit of commentary. After posting Who is Active? &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2008/12/31/a-gift-of-script-for-2009-who-is-active-redux.aspx"&gt;v7.22 on December 31&lt;/a&gt;, I expected to receive a huge amount of feedback from the community. Alas, there were a few issues:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;It turns out that December 31 is not a great day for a blog post that you would like to get lots of hits.&lt;/li&gt;&lt;li&gt;Apparently many readers were confused about where to actually download the script.&lt;/li&gt;&lt;li&gt;I was told that I need to document the thing better.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Luckily, some users did manage to download it, and I even received some feedback. Great feedback, primarily from a reader named Bill Kan. Thanks for all of your time, Bill!&amp;nbsp; I also discovered a couple of issues on my own, and added a new feature that I thought of while watching &lt;a href="http://scarydba.wordpress.com/"&gt;Grant Fritchey&lt;/a&gt; do an excellent talk at &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2009/01/16/new-england-data-camp-v1-0-complete-schedule.aspx"&gt;New England Data Camp v1.0&lt;/a&gt;.&lt;br&gt;&lt;br&gt;So now to address those three issues. I'm posting this post on a Wednesday, it's not a holiday, and it will hit midday, so that covers issue #1. For issue #2, see above and see below.&amp;nbsp; I think the download links are painfully obvious at this point.&amp;nbsp; And as for issue #3, well, I'm sorry to say that today is not the day for that one.&amp;nbsp; I've done a fairly good job of documenting the script in the script (download it and take a look), and I think most readers will be able to feel their way around well enough.&amp;nbsp; If you have any questions, post them here and I will be happy to answer. And eventually I will write up a comprehensive document on the thing. But until then, two out of three isn't bad... &lt;br&gt;&lt;br&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/attachment/11971.ashx"&gt;&lt;b&gt;Click here to download Who is Active? v7.30&lt;/b&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;Please give it a try and let me know what you think. I've run out of new feature ideas for the moment and could certainly use some input. If you are using it, please let me know what features you've found to
be helpful and how you're integrating it into your work. I'm hoping to
identify a number of use cases as talking points for the forthcoming
document on the script and actual user feedback will be key.&lt;/p&gt;&lt;p&gt;And, most importantly, enjoy! As I mentioned in December, this script has become a vital part of my toolkit; I have to say that it's made certain aspects of monitoring a lot easier and more interesting for me and I hope it does the same for you. &lt;br&gt;&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=11971" width="1" height="1"&gt;</description><enclosure url="http://www2.sqlblog.com/blogs/adam_machanic/attachment/11971.ashx" length="9263" type="application/zip" /><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/DMVs/default.aspx">DMVs</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/monitoring/default.aspx">monitoring</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/who+is+active/default.aspx">who is active</category></item><item><title>A Gift of Script for 2009: Who is Active, Redux</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2008/12/31/a-gift-of-script-for-2009-who-is-active-redux.aspx</link><pubDate>Wed, 31 Dec 2008 14:49:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:10841</guid><dc:creator>Adam Machanic</dc:creator><slash:comments>9</slash:comments><comments>http://www2.sqlblog.com/blogs/adam_machanic/comments/10841.aspx</comments><wfw:commentRss>http://www2.sqlblog.com/blogs/adam_machanic/commentrss.aspx?PostID=10841</wfw:commentRss><description>&lt;p&gt;Last year on December 31 &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2007/12/31/a-gift-of-script-for-2008-who-s-active-what-are-they-doing-and-who-is-blocked.aspx"&gt;I posted part of a larger monitoring script that I had been working on for a few months&lt;/a&gt;. I received lots of great feedback on the little script in both the comments and from people I was working with, and over the course of the last year I estimate that I have invested at least a couple of hundred hours in the script. &lt;a href="http://sqlblog.com/blogs/adam_machanic/attachment/10841.ashx"&gt;The result of all of this time is attached&lt;/a&gt;, and I hope that this script is as useful for others as it has been for me; I've been using it pretty much nonstop while modifying it and it has become an indispensable part of my toolkit. &lt;/p&gt;
&lt;p&gt;Alas, while I had planned to write a comprehensive blog post on the script for publication today, I simply don't have time to do it correctly at the moment--but I wanted to get the script out on the 31st in order to create a kind of tradition. So instead of telling you everything it can do, I will ask that you instead take a look inside the script, where I've done a fairly good job documenting both the parameters and the outputs.&amp;nbsp; I'll do a followup post soon (I hope) and do a better job of telling you about the various options.&amp;nbsp; In the meantime, I'll leave you with a list of the script's major features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Wait stats collection&lt;/b&gt;, if you enable the GET_WAITS switch. This mode aggregates the various resources that the tasks associated with the session are waiting on, and lets you know how long the tasks have been waiting.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Collection of lock information&lt;/b&gt;, if you enable the GET_LOCKS switch. A lot of effort went into this particular feature--all of the locks for each session are aggregated in an XML format, and work is done to map the various identifiers associated with each lock to actual object names so that you don't have to do the footwork yourself.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Information about sleeping SPIDs&lt;/b&gt; holding open transactions, if you enable the GET_TRANSACTION_INFO switch. If you're being blocked by a SPID that is not active, you should be able to find out about it. This option lets you do it.&amp;nbsp; As a bonus, it also pulls information about transaction log writes in any database in which the transaction has done a write.&lt;br&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Collection of the "outer" command/batch&lt;/b&gt;, if you enable the GET_OUTER_COMMAND switch. One of the comments on the script I posted last year asked why, if you issue SQL like "ALTER TABLE dbo.xx ALTER COLUMN yyy FLOAT NULL", you'll end up with statement text that looks like "UPDATE [zzz].[dbo].[xxx] SET [yyy] = [yyy]". This is an internal representation of what's actually happening, but in many cases is not esepecially useful for end-users. So if you want to see what was actually run, now you can.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Every expensive or potentially expensive option is now parameterized&lt;/b&gt;. I spent a lot of time tweaking performance and with no options running the thing is pretty fast. Enable some options--especially lock collection--and it will slow down considerably, so use these advanced features with care.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Enjoy, and &lt;b&gt;please keep sending feedback&lt;/b&gt;!&amp;nbsp; Let me know what else you would like to see, if you find bugs, etc.&amp;nbsp; I'll post updated versions as major changes are made. &lt;/p&gt;
&lt;p&gt;To finish I would like to thank a few of the people who had an impact on the evolution of this script over the past&amp;nbsp;12 months: Michael Condon, &lt;a href="http://sommarskog.se/"&gt;Erland Sommarskog&lt;/a&gt;, &lt;a href="http://sqlblog.com/blogs/aaron_bertrand/default.aspx"&gt;Aaron Bertrand&lt;/a&gt;, &lt;a href="http://sqlblog.com/blogs/louis_davidson/default.aspx"&gt;Louis Davidson&lt;/a&gt;, and &lt;a href="http://jmkehayias.blogspot.com/"&gt;Jonathan Kehayias&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Have a great 2009, everyone! &lt;br&gt;&lt;/p&gt;&lt;img src="http://www2.sqlblog.com/aggbug.aspx?PostID=10841" width="1" height="1"&gt;</description><enclosure url="http://www2.sqlblog.com/blogs/adam_machanic/attachment/10841.ashx" length="8670" type="application/x-zip-compressed" /><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/activity/default.aspx">activity</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/blocking/default.aspx">blocking</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/DMVs/default.aspx">DMVs</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/monitoring/default.aspx">monitoring</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/Performance/default.aspx">Performance</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/Scripts/default.aspx">Scripts</category><category domain="http://www2.sqlblog.com/blogs/adam_machanic/archive/tags/who+is+active/default.aspx">who is active</category></item></channel></rss>