<?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 'who is active' and 'DMVs'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=who+is+active,DMVs&amp;orTags=0</link><description>Search results matching tags 'who is active' and 'DMVs'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Who is Active v11.11</title><link>http://sqlblog.com/files/folders/beta/entry42453.aspx</link><pubDate>Thu, 22 Mar 2012 21:07:52 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:42453</guid><dc:creator>adam machanic</dc:creator><description>&lt;p&gt;Fixes the following issues:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Bug with transaction information not working for databases with "th" in their name&lt;/li&gt;&lt;li&gt;Bug with very large CPU times causing an overflow exception on SQL Server 2005&lt;/li&gt;&lt;li&gt;Excessive tempdb utilization caused by large string concatenation&lt;/li&gt;&lt;li&gt;Added host_process_id to additional_info collection&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;</description></item><item><title>Who is Active v11.03</title><link>http://sqlblog.com/files/folders/beta/entry36726.aspx</link><pubDate>Fri, 08 Jul 2011 15:31:21 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:36726</guid><dc:creator>adam machanic</dc:creator><description>Contains fixes for a couple of minor bugs that existed in v11.00.&lt;br&gt;</description></item><item><title>Twenty Nine Days of Activity Monitoring (A Month of Activity Monitoring, Part 30 of 30)</title><link>http://sqlblog.com/blogs/adam_machanic/archive/2011/04/30/twenty-nine-days-of-activity-monitoring-a-month-of-activity-monitoring-part-30-of-30.aspx</link><pubDate>Sat, 30 Apr 2011 14:00:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:35301</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;&lt;i&gt;This post is part 30 of a 30-part series about the &lt;a href="http://sqlblog.com/files/folders/35240/download.aspx"&gt;Who is Active&lt;/a&gt; stored procedure. A new post will run each day during the month of April, 2011. After April all of these posts will be edited and combined into a single document to become the basis of the Who is Active documentation.&lt;/i&gt;&lt;/p&gt;  &lt;hr&gt;  &lt;p&gt;&lt;b&gt;Pop quiz: &lt;/b&gt;What happens when you promise to write 30 posts on a topic, but you don’t plan properly and lose a bit of steam toward the end?&lt;/p&gt;  &lt;p&gt;Answer: A recap post, a day or two early! Woo hoo!&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;The month started&lt;/b&gt; with a few introductory posts. A &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/01/a-month-of-monitoring-part-1-of-30-a-brief-history-of-monitoring.aspx"&gt;history of monitoring&lt;/a&gt; (from my point of view), some information on Who is Active’s &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/02/who-is-active-design-philosophy-a-month-of-activity-monitoring-part-2-of-30.aspx"&gt;design philosophy&lt;/a&gt;, and a few words on the Who is Active &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/03/who-is-active-the-license-a-month-of-activity-monitoring-part-3-of-30.aspx"&gt;license&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The key takeaways from these first posts? The monitoring story has been pretty poor for most of SQL Server’s history. It’s better now, but it’s still a lot of work. Who is Active was created to make things more accessible. It’s free, with a few restrictions designed to keep people who make money from monitoring from making money on Who is Active. Anyone else can and should use and enjoy.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Next I got new users up to speed&lt;/b&gt;. My post on &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/04/installing-who-is-active-a-month-of-activity-monitoring-part-4-of-30.aspx"&gt;installation&lt;/a&gt; covered security considerations, followed by a post on &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/05/less-data-is-more-data-a-month-of-monitoring-part-5-of-30.aspx"&gt;why you may not see as much data as you're used&lt;/a&gt; to when you first start using Who is Active. I continued with a post on the &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/06/who-is-active-options-a-month-of-monitoring-part-6-of-30.aspx"&gt;various options&lt;/a&gt; supported by the procedure (plus a nod to the online help mode) and another post describing the &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/07/who-is-active-default-columns-day-1-a-month-of-activity-monitoring-part-7-of-30.aspx"&gt;default output columns&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;One of the more important posts of the month described how Who is Active treats &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/08/active-request-sleeping-session-a-month-of-activity-monitoring-part-8-of-30.aspx"&gt;active requests and sleeping sessions&lt;/a&gt;. This can be a confusing area for new users, since it's not always obvious what's going on unless you're looking in the right place at the output (the [status] column).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Once the refresher was finished I began covering &lt;b&gt;some of the basic options exposed by the procedure&lt;/b&gt;. &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/09/deciding-what-not-to-see-a-month-of-activity-monitoring-part-9-of-30.aspx"&gt;Filters &lt;/a&gt;were one of the first things I implemented, so it was a logical place to start (the "not" filters came much later). &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/10/commands-batches-and-the-mysteries-of-text-a-month-of-activity-monitoring-part-10-of-30.aspx"&gt;Seeing the query text&lt;/a&gt; is a key part of the procedure's functionality, and that was next on my list. If you're not sure what the [sql_text] column means, this post will set the record straight.&lt;/p&gt;&lt;p&gt;The ability to see the query text is nice, but so is the ability to get a &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/11/planning-for-success-a-month-of-activity-monitoring-part-11-of-30.aspx"&gt;query plan&lt;/a&gt;--and of course Who is Active supports that too. And since everything a query does is transactional, the procedure allows users to collect information about &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/12/the-almighty-transaction-a-month-of-activity-monitoring-part-12-of-30.aspx"&gt;what those transactions are up to&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;The next section of the month was all about query processing&lt;/b&gt;. I started with a couple of background posts: One on &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/13/how-queries-are-processed-a-month-of-activity-monitoring-part-13-of-30.aspx"&gt;how the query processor works&lt;/a&gt; (at a somewhat high level), and another on what blocking &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/14/blocking-blockers-and-other-b-words-a-month-of-activity-monitoring-part-14-of-30.aspx"&gt;&lt;i&gt;really&lt;/i&gt; means&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Who is Active exposes two different modes that help with analysis of real-time waits. My 15th post of the month covered the default--&lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/15/seeing-the-wait-that-matters-most-a-month-of-activity-monitoring-part-15-of-30.aspx"&gt;lightweight--collection mode&lt;/a&gt;. My followup post covered the more extensive &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/16/seeing-all-of-the-waits-a-month-of-activity-monitoring-part-16-of-30.aspx"&gt;full waits collection mode&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Sometimes a query plan and wait information isn't quite enough to diagnose a performance issue&lt;/b&gt;. What if the query plan usually works well, but isn't performing properly only in this specific case? Who is Active &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/17/is-this-normal-a-month-of-activity-monitoring-part-17-of-30.aspx"&gt;has a feature to help you figure that out&lt;/a&gt;. And what if you need &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/18/getting-more-information-a-month-of-activity-monitoring-part-18-of-30.aspx"&gt;a bit more information&lt;/a&gt; on some of the settings that the request is using?&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Mining wait information yields some amazing returns&lt;/b&gt;. One of the additional pieces of information that you can get is the &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/19/why-am-i-blocked-a-month-of-activity-monitoring-part-19-of-30.aspx"&gt;actual name of the object that's causing a block&lt;/a&gt;. Another thing you can see is &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/20/the-node-knows-a-month-of-activity-monitoring-part-20-of-30.aspx"&gt;the exact node within a query plan where a task is currently doing work&lt;/a&gt;. You can (and should!) also use waits to figure out &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/21/analyzing-tempdb-contention-a-month-of-activity-monitoring-part-21-of-30.aspx"&gt;whether &lt;i&gt;tempdb &lt;/i&gt;is properly configured&lt;/a&gt;. There are still more tricks you can play with waits, but they'll have to wait for a future post.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Like wait information, lock data can also be mined.&lt;/b&gt; However, there is so much locks information that the real challenge is rendering it in a human-readable manner. Who is Active does that using a special &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/22/the-key-to-your-locks-a-month-of-activity-monitoring-part-22-of-30.aspx"&gt;custom XML format&lt;/a&gt;. The procedure also helps with another type of blocker analysis, in the form of finding the "&lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/23/leader-of-the-block-a-month-of-activity-monitoring-part-23-of-30.aspx"&gt;lead blocker&lt;/a&gt;."&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Once you've figured out what information you're interested in, why not &lt;b&gt;set up the output so that you can see the information the way you want to see it&lt;/b&gt;? Who is Active helps with this by allowing users to &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/24/the-output-of-your-dreams-a-month-of-activity-monitoring-part-24-of-30.aspx"&gt;dynamically customize output columns and sort order&lt;/a&gt; in a few different ways. And while you could always run Who is Active interactively, that might get a bit dull. &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/25/capturing-the-output-a-month-of-activity-monitoring-part-25-of-30.aspx"&gt;Automated data collection&lt;/a&gt; is a much nicer methodology in many cases.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Most of the numbers shown by Who is Active are cumulative. But oftentimes it's more interesting to &lt;b&gt;compare data between two snapshots&lt;/b&gt;. The procedure can help you do that, using its &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/26/delta-force-a-month-of-activity-monitoring-part-26-of-30.aspx"&gt;delta mode&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;What fun would a month of Who is Active be without an official release&lt;/b&gt;? &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/27/who-is-active-v11-00-a-month-of-activity-monitoring-part-27-of-30.aspx"&gt;v11.00 has numerous new features&lt;/a&gt;, several of which were perfected this month thanks to feedback I received on the various posts in the series. It's great to have such enthusiastic users! Some of these new features didn't make it into prior posts, and other existing features are a bit hidden. So I did a writeup covering the &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/28/who-is-active-s-hidden-gems-a-month-of-activity-monitoring-part-28-of-30.aspx"&gt;more important things that you may not have noticed&lt;/a&gt; while working with Who is Active.&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I finished the month with a discussion on &lt;b&gt;security for slightly tougher situations&lt;/b&gt;. I hope that the &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/29/access-for-all-a-month-of-activity-monitoring-part-29-of-30.aspx"&gt;module signing technique&lt;/a&gt; will allow Who is Active to be used in a number of places where security auditing requirements have made things difficult.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;And that's that. A month of activity monitoring with Who is Active. Thank you for reading! Next, this text is going to be edited, expanded in places, and put into a much more comprehensive form. Watch your RSS reader for more information.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Enjoy!&lt;/b&gt; &lt;br&gt;&lt;/p&gt;</description></item><item><title>Access for All! (A Month of Activity Monitoring, Part 29 of 30)</title><link>http://sqlblog.com/blogs/adam_machanic/archive/2011/04/29/access-for-all-a-month-of-activity-monitoring-part-29-of-30.aspx</link><pubDate>Fri, 29 Apr 2011 14:00:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:35300</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;&lt;i&gt;This post is part 29 of a 30-part series about the &lt;a href="http://sqlblog.com/files/folders/35240/download.aspx"&gt;Who is Active&lt;/a&gt; stored procedure. A new post will run each day during the month of April, 2011. After April all of these posts will be edited and combined into a single document to become the basis of the Who is Active documentation.&lt;/i&gt;&lt;/p&gt;  &lt;hr&gt;  &lt;p&gt;Early in the month I discussed &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/04/installing-who-is-active-a-month-of-activity-monitoring-part-4-of-30.aspx"&gt;basic security requirements&lt;/a&gt; for Who is Active. I mentioned the VIEW SERVER STATE permission and the fact that I consider it to be “a relatively low barrier to entry.”&lt;/p&gt;  &lt;p&gt;But what if, in your organization, it’s not? &lt;b&gt;Auditing requirements being what they are, you might be required to lock things down&lt;/b&gt;. And granting someone full and unrestricted VIEW SERVER STATE may simply not be an option.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Enter module signing&lt;/b&gt;. By securing Who is Active (or any other securable, for that matter) via inherited permissions, it’s often possible to get around auditing requirements, as long as the module itself has been reviewed. This is not at all a difficult thing to do, but in my experience most DBAs haven’t played much with signed modules. Today I’ll show you how quick and easy it can be to set things up.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Start by creating a certificate.&lt;/b&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;USE master       &lt;br&gt;GO&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;CREATE CERTIFICATE WhoIsActive_Permissions       &lt;br&gt;ENCRYPTION BY PASSWORD = '1bigHUGEpwd4WhoIsActive!'        &lt;br&gt;WITH SUBJECT = 'Who is Active',        &lt;br&gt;EXPIRY_DATE = '9999-12-31'        &lt;br&gt;GO&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Once you have a certificate in place, you can create a login from the certificate. The goal is to grant permissions, and to do that you need a principal with which to work; a certificate does not count. A login based on the certificate uses the certificate’s cryptographic thumbprint as its identifier. These logins are sometimes referred to as “loginless logins,” but &lt;a href="http://dataeducation.com/creating-proxies-in-sql-server/"&gt;I refer to them as “proxy logins”&lt;/a&gt; since that’s what they’re used for: proxies for the sake of granting permissions. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;CREATE LOGIN WhoIsActive_Login       &lt;br&gt;FROM CERTIFICATE WhoIsActive_Permissions        &lt;br&gt;GO&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The login can be granted any permission that can be granted to a normal login. For example, VIEW SERVER STATE:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;GRANT VIEW SERVER STATE       &lt;br&gt;TO WhoIsActive_Login        &lt;br&gt;GO&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Once the permission has been granted, the certificate can be used to sign the module—in this case, Who is Active. When the procedure is executed, a check will be made to find associated signatures. The thumbprint of the certificates and/or keys used to sign the module will be checked for associated logins, and any permissions granted to the logins will be available within the scope of the module—meaning that the caller will temporarily gain access.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;ADD SIGNATURE TO sp_WhoIsActive       &lt;br&gt;BY CERTIFICATE WhoIsActive_Permissions        &lt;br&gt;WITH PASSWORD = '1bigHUGEpwd4WhoIsActive!'        &lt;br&gt;GO&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;b&gt;Getting to this step will be enough to allow anyone with EXECUTE permission on Who is Active to exercise most of its functionality&lt;/b&gt;. There are a couple of notes and caveats: First of all, every time you ALTER the procedure (such as when upgrading to a new version), the signature will be dropped and the procedure will have to be re-signed. You won’t have to create the certificate or the login again; you’ll just have to re-run that final statement. Second, you’ll only be able to use &lt;i&gt;most&lt;/i&gt; of the functionality. Certain features, such as blocked object resolution mode, won’t operate properly, depending on whether the caller has access to the database in which the block is occurring. This may or may not be a problem—it depends on your environment and what users need to see—and Who is Active itself won’t throw an exception. An error message will be returned somewhere in the results, depending on what the user has tried to do. &lt;/p&gt;  &lt;p&gt;If you would like to grant database-level permissions based on the certificate login so as to avoid these errors, that’s doable to. Just do something like:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;USE AdventureWorks       &lt;br&gt;GO&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;CREATE USER WhoIsActive_User       &lt;br&gt;FOR LOGIN WhoIsActive_Login        &lt;br&gt;GO&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_addrolemember        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'db_datareader',        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'whoisactive_user'        &lt;br&gt;GO&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This will allow Who is Active to figure out what the various blocked or locked object names are. Since the login is just a proxy no one can actually log in and get direct access to read the data, so this isn’t something I consider to be a security risk. However, keep in mind that if anyone has the password for the certificate and sufficient privileges in &lt;i&gt;master&lt;/i&gt;, a new module could be created and signed. Keep the password secure, and make sure to carefully audit to catch any infractions before they become a risk.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Security policy should never be a reason to limit your monitoring choices&lt;/b&gt;. Module signing is a powerful tool for Who is Active in addition to many other applications. I highly recommend studying it in detail in order to enhance your ability to provide high-quality, totally flexible, and completely secure solutions.&lt;/p&gt;</description></item><item><title>Who is Active's Hidden Gems (A Month of Activity Monitoring, Part 28 of 30)</title><link>http://sqlblog.com/blogs/adam_machanic/archive/2011/04/28/who-is-active-s-hidden-gems-a-month-of-activity-monitoring-part-28-of-30.aspx</link><pubDate>Thu, 28 Apr 2011 14:00:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:35114</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;&lt;i&gt;This post is part 28 of a 30-part series about the &lt;a href="http://sqlblog.com/files/folders/35240/download.aspx"&gt;Who is Active&lt;/a&gt; stored procedure. A new post will run each day during the month of April, 2011. After April all of these posts will be edited and combined into a single document to become the basis of the Who is Active documentation.&lt;/i&gt;&lt;/p&gt;  &lt;hr&gt;  &lt;p&gt;&lt;b&gt;Over the past month this series has covered a lot of ground.&lt;/b&gt; After writing almost 30 blog posts on the stored procedure it’s interesting to look back and see the fact that it’s gotten much bigger and more complex than I realized. Kind of like watching a plant grow, you don’t notice the day-to-day changes until one day you go to water it and see that it’s taken over your entire garden.&lt;/p&gt;  &lt;p&gt;A few things that I’ve added along the way have been especially useful, but there hasn’t been a good place to mention them thus far in the series. With just three posts left for the month, now is the time.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Always Show Blockers&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;In &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/09/deciding-what-not-to-see-a-month-of-activity-monitoring-part-9-of-30.aspx"&gt;a post earlier this month&lt;/a&gt; I talked about filters. Filters let you decide exactly what you want to see, and what you not don’t want to see (“not” filters). But sometimes you have no choice: if you’re filtering so that you only see session 123, and it’s being blocked by session 456, you’ll also see information about session 456. The idea is that you should &lt;i&gt;always&lt;/i&gt; get enough context to fully evaluate the problem at hand. Even if it means that you see more information than you were intending to see the first time around. You probably would have asked for 456 next anyway.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;“RUNNABLE” Waits&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;In &lt;i&gt;@get_task_info = 2&lt;/i&gt; mode, you may see waits called “RUNNABLE.” This could strike you as an oddity, given that &lt;i&gt;there is no such wait type&lt;/i&gt; in SQL Server. I wanted to show &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/13/how-queries-are-processed-a-month-of-activity-monitoring-part-13-of-30.aspx"&gt;tasks on the runnable queue&lt;/a&gt;, and making up a fake wait type seemed like a reasonable way of accomplishing the task. In practice, it has worked extremely well—I’ve used this feature countless times to help understand scheduler contention on a SQL Server instance.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Accurate CPU Time Deltas&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;CPU time is a tricky metric. It gets handled by Who is Active’s &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/26/delta-force-a-month-of-activity-monitoring-part-26-of-30.aspx"&gt;delta mode&lt;/a&gt;, and has for several versions. But historically, never very well. The data &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/02/who-is-active-design-philosophy-a-month-of-activity-monitoring-part-2-of-30.aspx"&gt;simply isn’t represented in an easily-obtainable fashion&lt;/a&gt; in the core DMVs. Recently I decided to dig deeper into this problem and discovered that I could get better numbers from some of the thread-specific DMVs. They’re cumulative numbers, based on the lifetime of the entire thread—not too good for the usual Who is Active output. But for snapshot and delta purposes, just about perfect. Meaning that in v11.00 of Who is Active, you can see the [CPU] column show a value of 0, while the [CPU_delta] column shows a value in the thousands. It’s not a bug. It’s a feature. (It really is!)&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Text Query Plans and the XML Demon&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;SQL Server 2005 introduced query plans as XML. Management Studio knew how to render these plans graphically. And we were able to pull the plans from DMVs. Life was great. Except, perhaps, when you actually wanted to view one of these plans, and you had to save the thing out to a .SQLPLAN file, close the file, then re-open it. That’s about three steps too many for my taste, so I was overjoyed when the Management Studio team decided to wire things up the right way in SQL Server 2008. Click on a showplan XML document, see a graphical plan. Simple as that. &lt;/p&gt;  &lt;p&gt;Unfortunately, the XML data type has its own issues, including one particularly nasty arbitrary limitation that has to do with nesting depth. The idea is to make sure that XML indexes don’t crash and burn too often (not a big concern for me, given that I’ve never seen one used in a production environment—but I digress). The problem is that query plans are heavily nested. And to get that nice graphical plan workflow, SSMS needs the plan rendered as XML. &lt;/p&gt;  &lt;p&gt;In prior versions of Who is Active I gave up and returned either an error or a NULL. But in v11.00 I decided to make things a bit better. If the nesting issue occurs, Who is Active will now return the plan as XML encapsulated in some other XML in a text format, along with instructions on how to view the plan. This won’t give you a nice one-click experience, but it will give you the ability to use Who is Active to see some of the bigger plans that are causing performance issues.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Service Broker Needs Love Too&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;One of the most interesting features of Service Broker is activation. But a vexing design choice on behalf of the Service Broker team was to make activation procedures launch as system sessions. This means, among other things, that prior versions of Who is Active filtered them right out of the default view. To see them you’d have to enable &lt;i&gt;@show_system_spids&lt;/i&gt;. And then you’d have to ignore all of the other system stuff. And you’d get woefully bad time information (no, the activation process hasn’t been running for 25 days; that’s the last time you restarted the SQL Server instance). In Who is Active v11.00 this has been fixed. Service Broker activation processes are now displayed by default along with other user activity. And I found a way to fix the timing issue, thanks to some advice on Twitter from Remus Rusanu, one of the guys who originally worked on Service Broker. So if you’re using activation and monitoring with Who is Active, life is good.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Homework&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;The homework section of this series is officially closed. Your assignment is to go enjoy the rest of your day.&lt;/p&gt;</description></item><item><title>Who is Active v11.00 (A Month of Activity Monitoring, Part 27 of 30)</title><link>http://sqlblog.com/blogs/adam_machanic/archive/2011/04/27/who-is-active-v11-00-a-month-of-activity-monitoring-part-27-of-30.aspx</link><pubDate>Wed, 27 Apr 2011 14:00:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:35113</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;&lt;i&gt;This post is part 27 of a 30-part series about the &lt;a href="http://sqlblog.com/files/folders/35240/download.aspx"&gt;Who is Active&lt;/a&gt; stored procedure. A new post will run each day during the month of April, 2011. After April all of these posts will be edited and combined into a single document to become the basis of the Who is Active documentation.&lt;/i&gt;&lt;/p&gt;  &lt;hr&gt;  &lt;p&gt;&lt;b&gt;Thanks to your feedback over the past month, I’ve managed to get a lot of work done on the next version of Who is Active.&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;So much work, in fact, that I’ve finished a new major release.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://sqlblog.com/files/folders/35240/download.aspx"&gt;&lt;b&gt;Click here to download Who is Active v11.00&lt;/b&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There are numerous enhancements in this release. In no particular order:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;CPU deltas use-time thread-based metrics for more accurate data (use both @delta_interval and @get_task_info = 2)&lt;/li&gt;    &lt;li&gt;command_type information added to [additional_info] column for active requests &lt;/li&gt;    &lt;li&gt;Modified elapsed time logic to retrieve more accurate timing information for active system SPIDs&lt;/li&gt;    &lt;li&gt;SQL Agent job info (job name and step name) is now included in the additional_info column (use @get_additional_info = 1) &lt;/li&gt;    &lt;li&gt;If there is a lock wait, information about the blocked object (name, schema name, and ID) is now included in the additional_info column (use both @get_additional_info = 1 and @get_task_info = 2) &lt;/li&gt;    &lt;li&gt;Service Broker activated tasks are now shown by default, without using @show_system_spids mode. The program_name column contains the queue_id and database_id associated with the activation procedure&lt;/li&gt;    &lt;li&gt;Various numeric columns, including reads, writes, cpu, etc, have been made nullable. These will occasionally return NULL, on extremely active systems where the DMVs return data more slowly than queries start and complete &lt;/li&gt;    &lt;li&gt;Query plans that cannot be rendered due to XML type limitations are now returned in an encapsulated format, with instructions, rather than sending back an error &lt;/li&gt;    &lt;li&gt;Added wait information for OLEDB/linked server waits &lt;/li&gt;    &lt;li&gt;Wait collection will now "downgrade" to get_task_info = 1 style data if no other information is available in get_task_info = 2 mode &lt;/li&gt;    &lt;li&gt;Added header information to online help &lt;/li&gt;    &lt;li&gt;Added a login_time column to the output &lt;/li&gt;    &lt;li&gt;The duration for sleeping sessions is now the sleep time, rather than the time since login&lt;/li&gt;    &lt;li&gt;Fixed various bugs&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I’ve written about several of these things over the past month, and there are a couple of posts left for the remainder of the month, so I won't elaborate here. &lt;/p&gt;  &lt;p&gt;Thank you, thank you, and thank you again to everyone who has taken the time to give me feedback and/or report bugs! Who is Active would not be what it is without you! &lt;/p&gt;&lt;p&gt;&lt;b&gt;I would especially like to thank Paul White. &lt;/b&gt;Paul has acted as my unofficial "lead QA engineer" for the past few versions. He's found some very interesting bugs in my code, in addition to pointing out some quirks in the DMVs that I wasn’t handling properly. Thanks, Paul, for the great job you’ve done!&lt;/p&gt;  &lt;p&gt;&lt;b&gt;One other thing I would like to point out is an addition to the header: a donation link&lt;/b&gt;. Several people recently have asked me how to donate, and I didn’t have a good answer. Now, I do.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://tinyurl.com/WhoIsActiveDonate"&gt;&lt;b&gt;Use this link to support the Who is Active project!&lt;/b&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;While I feel strange asking for money, the truth is that I’ve invested well over a thousand hours in the stored procedure, documentation, and support (I respond to EVERY e-mail I receive from Who is Active users). If you’ve been able to improve your day-to-day performance thanks to Who is Active, it would be great if you—or even better, your employer—could help support my work on the project. &lt;b&gt;I’ve listed a recommended donation of $40 per installed instance, but please donate however much you feel Who is Active is worth to you and/or your organization.&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Thanks again, and enjoy!&lt;/p&gt;</description></item><item><title>Who is Active? v11.00</title><link>http://sqlblog.com/files/folders/release/entry35240.aspx</link><pubDate>Wed, 27 Apr 2011 04:20:03 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:35240</guid><dc:creator>adam machanic</dc:creator><description>&lt;p&gt;Who is Active? is a comprehensive server activity stored procedure 
based on the SQL Server 2005 and 2008 dynamic management views (DMVs). 
Think of it as sp_who2 on a hefty dose of anabolic steroids. Features 
supported by Who is Active? include:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Server activity 
collection, including data about currently running T-SQL, server 
resources consumed by the request, and query plan collection&lt;/li&gt;&lt;li&gt;Real-time wait statistics collection and blocker reporting&lt;/li&gt;&lt;li&gt;Delta collection mode, in order to find out what processes are doing over time&lt;/li&gt;&lt;li&gt;A
 number of filter options to help you narrow down the scope of data 
returned, the order of rows, and the number and order of output columns&lt;/li&gt;&lt;li&gt;Ability to collect to a table, rather than sending the data back as a rowset&lt;/li&gt;&lt;li&gt;An online help system to help you figure out what options are available. Use the @help=1 option to hit the ground running.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;License:&lt;/p&gt;
&lt;p&gt;Who
 is Active? is free to download and use for personal, educational, and 
internal corporate purposes, provided that the included comment header 
is preserved. Redistribution or sale of Who is Active?, in whole or in 
part, is prohibited without the author's express written consent. &lt;/p&gt;
&lt;p&gt;Donate! Support this project: &lt;a href="http://tinyurl.com/WhoIsActiveDonate"&gt;http://tinyurl.com/WhoIsActiveDonate&lt;/a&gt;&amp;nbsp; &lt;br&gt;&lt;/p&gt;&lt;hr&gt;
&lt;p&gt;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Change log for the most recent several versions: &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Who is Active v11.00 &lt;/p&gt;&lt;ul&gt;&lt;li&gt;Added wait information for OLEDB/linked server waits&lt;/li&gt;&lt;li&gt;Wait
 collection will now "downgrade" to get_task_info = 1 style data if no 
other information is available in get_task_info = 2 mode&lt;/li&gt;&lt;li&gt;Fixed sort order bug w/ multicolumn sorts&lt;/li&gt;&lt;li&gt;Added header information to online help&lt;/li&gt;&lt;li&gt;Added a login_time column to the output&lt;/li&gt;&lt;li&gt;The duration for sleeping sessions is now the sleep time, rather than the time since login&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Who is Active v10.99&lt;/p&gt;&lt;ul&gt;&lt;li&gt;CPU deltas can now use real-time thread-based metrics for more accurate data (use both @delta_interval and @get_task_info = 2) &lt;br&gt;&lt;/li&gt;&lt;li&gt;command_type information added to [additional_info] column for active requests&lt;br&gt;&lt;/li&gt;&lt;li&gt;Query plans that are not able to be rendered due to XML data type limitations will now be returned in an encapsulated text form&lt;br&gt;&lt;/li&gt;&lt;li&gt;Fixed bug where system processes were sometimes reporting start times in the future (thanks, Neil Hambly!)&lt;/li&gt;&lt;li&gt;Fixed bug where @get_locks sometimes failed with a constraint error (thanks, various reporters!)&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Who is Active v10.83&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Modified elapsed time logic to retrieve more accurate timing information for system SPIDs, in many cases&lt;br&gt;&lt;/li&gt;&lt;li&gt;Fixed bug where @get_task_info = 2 was adding an "N" before some waits&lt;/li&gt;&lt;li&gt;Fixed bug where tempdb_allocations was being incorrectly calculated for active requests&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Who is Active v10.76&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;b&gt;Enhancements&lt;/b&gt; &lt;br&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;SQL Agent job info&lt;/b&gt;
 (job name and step name) is now included in the additional_info column 
(use @get_additional_info = 1) (thanks, Argenis Fernandez!)&lt;br&gt;&lt;/li&gt;&lt;li&gt;If there is a lock wait, &lt;b&gt;information about the blocked object&lt;/b&gt; (name, 
schema name, and ID) is now included in the additional_info column (use 
both @get_additional_info = 1 and @get_task_info = 2)&lt;/li&gt;&lt;li&gt;Service Broker &lt;b&gt;activated tasks are now shown by default&lt;/b&gt;, without 
using @show_system_spids mode. The program_name column contains the 
queue_id&lt;/li&gt;&lt;li&gt;Various numeric columns, including reads, writes, cpu, 
etc, have been made nullable. These will occasionally return NULL, on 
extremely active systems where the DMVs return data more slowly than 
queries start and complete &lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;b&gt;Updates&lt;/b&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;Removed workaround to handle MARS bug documented here: &lt;a href="http://connect.microsoft.com/SQLServer/feedback/details/490178/request-id-in-sys-dm-os-tasks-wrong-when-using-mars" target="_blank"&gt;http://connect.microsoft.com/SQLServer/feedback/details/490178/request-id-in-sys-dm-os-tasks-wrong-when-using-mars&lt;/a&gt; ... 
this was done in order to fix an issue where task information could not 
be populated in systems that had been up for some time (thanks, Michael 
Codanti!)&lt;br&gt;
&lt;/li&gt;&lt;li&gt;Modified the way transaction data is collected; @get_transaction_info should now perform better than it previously did
&lt;/li&gt;&lt;li&gt;Modified central collection mechanism to read fewer rows from sysprocesses on each pass.&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;blockquote&gt;&lt;b&gt;Bug Fixes&lt;/b&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;ul&gt;&lt;li&gt;Removed get_original_login column from @get_additional_info option, 
in order to make the procedure once again fully compatibly with all 
versions of SQL Server 2005 and SQL Server 2008&lt;br&gt;
&lt;/li&gt;&lt;li&gt;Fixed bug where @get_transaction_info would throw an exception when
 run on servers set to use a non-US English language (thanks, Tobias 
Ortmann!)&lt;br&gt;
&lt;/li&gt;&lt;li&gt;Fixed bug where @get_task_info = 0 erroneously collected blocking information&lt;/li&gt;&lt;li&gt;Fixed issue where on SQL Server instance start-up, SPIDs have a start_date of 1900-01-01 
until recovery is complete, which was causing an overflow exception (thanks, Michael Codanti and Allen White!)&lt;/li&gt;&lt;/ul&gt;&amp;nbsp;&lt;br&gt;
&lt;p&gt;Who is Active v9.98 (10.00 Release Candidate)&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&lt;b&gt;Added new option, @get_additional_info&lt;/b&gt;:
 Returns a column called [additional_info] that contains various 
non-performance-related information sourced from the sessions and 
requests DMVs&lt;/li&gt;&lt;li&gt;&lt;b&gt;Fixed @get_avg_time&lt;/b&gt;: This option had been broken for several versions. (thanks, Ola Hallengren)&lt;/li&gt;&lt;li&gt;&lt;b&gt;Workspace memory greatly decreased&lt;/b&gt;:
 In some cases the proc would ask for a workspace memory grant of up to 
200MB. This was problematic in situations with a lot of concurrent 
activity. This version reduces the grant to under 4MB in the vast 
majority of cases.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;NOTE&lt;/b&gt;: The workspace memory fix is a
 tradeoff, and the opposite side of the coin is that the proc will now 
cause slightly more activity in tempdb. I need testers to compare the 
performance of v9.90 to v9.98. &lt;b&gt;Please &lt;/b&gt;give it a try and &lt;b&gt;let me know your results&lt;/b&gt; as soon as possible!&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who is Active v9.90&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Discovered
 that due to inconsistent results from DMVs on servers under extreme 
load, the script will very rarely throw a unique key exception. Added 
IGNORE_DUP_KEY to the two main temp tables used in the script, in order 
to avoid this situation. (Thanks, Sankar Reddy and others)&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who is Active v9.89&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Fixed a bug where wait types were prefixed with an N in the wait_info column&lt;/li&gt;&lt;li&gt;Changed
 the filter for system SPIDs on sysprocesses to use the hostprocess 
column rather than hostname (thanks, Dan [last name unknown] and Erland 
Sommarskog)&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who 
is Active v9.87&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;First stab at international database support&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Switched
 from VARCHAR to NVARCHAR almost everywhere appropriate&lt;/li&gt;&lt;li&gt;sql_text,
 sql_command, locks, login_name, wait_info, database_name, and 
other areas should all show the full set of available characters&lt;/li&gt;&lt;li&gt;Not
 currently supporting double-byte characters in the tran_log_writes 
column, due to issues with right-to-left languages causing SSMS to 
mangle the output&lt;/li&gt;&lt;li&gt;Use of characters in identifier names (e.g. 
database names, table names, etc) from unsupported character ranges per 
the W3C XML standard may cause Who is Active to throw a run-time 
exception. &lt;b&gt;This is something I need your help with.&lt;/b&gt; Are you using
 characters in your identifier names in the ranges 1-8, 11-12, 14-31, 
55296-57343, or 65534-65535? I suspect the answer is no; please let me 
know if I'm mistaken.&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Changed the CREATE syntax at the top 
so that the stored procedure will not longer get dropped and re-created,
 thereby ensuring that existing permissions won't get overwritten when 
upgrading to a new version&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Please let me know if you're 
granting access to Who is Active using module signing, in which case I 
will attempt to make further modifications in this area&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who
 
is Active v9.72&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Removed reference to 
sys.dm_exec_query_memory_grants; now getting granted query memory info 
from sys.dm_exec_requests&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Who is Active is now compatible 
with all versions of SQL Server 2005 and SQL Server 2008&lt;br&gt;&lt;/li&gt;&lt;li&gt;Thanks
 for testing help, Mladen Prajdic&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who 
is Active v9.71&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Fixed a bug where session_id was being 
converted to TINYINT rather than SMALLINT (thanks, Linchi Shea)&lt;/li&gt;&lt;li&gt;Fixed

 a bug where self-blocking sessions in sysprocesses were incorrectly 
being shown (thanks, Jason Pease)&lt;/li&gt;&lt;li&gt;Fixed a bug where block 
leaders was causing a recursion overflow (thanks, Sankar Reddy)&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who

 
is Active v9.68&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Fixed a bug where an internal UNIQUE 
constraint could occasionally be violated (session_id/kpid is not, as it
 turns out, truly unique in sysprocesses -- needed to add ecid to the 
key)&lt;/li&gt;&lt;li&gt;Fixed a bug where ignoring CXPACKET waits would cause other
 wait types to not bubble up in the default @get_task_info = 1 mode&lt;/li&gt;&lt;li&gt;Fixed

 a bug where PREEMPTIVE wait types were not showing properly in some 
cases, due to the task state being set as RUNNABLE rather than SUSPENDED
 in sys.dm_os_tasks&lt;/li&gt;&lt;li&gt;Now showing the actual latch type for 
LATCH_* waits&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who 
is Active v9.62 &lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Further improved performance of the default 
"lightweight" wait collection mode (@get_task_info = 1).&lt;/li&gt;&lt;li&gt;Changed
 the name of the tempdb_writes column to tempdb_allocations (thanks 
Linchi Shea)&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who is Active v9.59&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Fixed
collation


 bug where some database names would cause an error to occur
due to special characters used as part of the script's processing work&lt;/li&gt;&lt;li&gt;Added


 log used kB information to the transaction_writes column&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who


 is Active v9.55&lt;br&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Massive re-work of the core queries, 
resulting in &lt;b&gt;greatly improved performance&lt;/b&gt; and more consistent 
results even in high-throughput environments&lt;br&gt;&lt;/li&gt;&lt;li&gt;Created a new&lt;b&gt;
 lightweight wait collection mode&lt;/b&gt;, used by default. This mode 
collects only the top non-CXPACKET wait, giving preference to blockers.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;To


 see full wait and task info, use the new option @get_task_info = 2&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;New


 feature added that&lt;b&gt; shows all sessions blocking those included in the
 base filter criteria&lt;/b&gt;, whether or not they would normally be 
returned.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;To
see the feature in action, create a new database and have a session use
it. Then fire up another session and try to drop the database. The
second session will be blocked, and by default previous versions of the
script would not have returned the blocking session because it is not
active, nor does it have an open session. Version 9.55 will return the
blocking session.&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Release candidate for the next 
"official" version. &lt;b&gt;Please test!&lt;/b&gt;&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who is 
Active v9.07 &lt;br&gt;&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Flipped the version to v9.0!&lt;/li&gt;&lt;li&gt;Added 
nodeId information when collecting CXPACKET waits&lt;/li&gt;&lt;li&gt;Made the help 
output even nicer&lt;/li&gt;&lt;li&gt;Added a new option, @show_system_spids&lt;b&gt; &lt;/b&gt;which,


 when set to 1, makes the tool show system SPIDs as well as user SPIDs&lt;/li&gt;&lt;li&gt;Changed


 @get_sleeping_spids to @show_sleeping_spids, in order to align with the
 naming used by the rest of the procedure&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;br&gt;&lt;/p&gt;
&lt;p&gt;Who


 is Active v8.99&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Added
additional workarounds for cases where sys.dm_exec_requests does not
output proper or meaningful statement offsets. The latest issues I've
identified occur when a query is calling a scalar UDF. The offsets and
the sql_handle are not updated in a single operation, so it is possible
to get strange results. I've added a couple of checks to try to avoid
this in most cases, but the issue will not actually be solved until the
SQL Server team fixes it in the engine.&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Want it fixed? Vote 
here: &lt;a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=478601"&gt;https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=478601&lt;/a&gt;&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who


 is Active? v8.96&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Dynamic sort ordering&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Removed 
@sort_column and @sort_column_direction parameters.&lt;/li&gt;&lt;li&gt;Replaced 
with @sort_order parameter, which accepts a list of columns and sort 
directions (completely injection-safe, of course)&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;"Not" 
filters&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Added
new @not_filter and @not_filter_type parameters which behave the same
as the @filter and @filter_type but do the opposite. Great for when you
have service accounts, etc, that you don't want to see information about&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Improved


 the online help (@help=1) option&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Added a second table 
containing all of the output columns&lt;/li&gt;&lt;li&gt;Improved the layout of the 
first table&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who is Active? v8.89&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;&amp;nbsp;Removed


 reference to SQL Server 2008-specific DMV column (parent_task_address)&lt;br&gt;&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Tasks


 and requests are now related via kpid from sysprocesses&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who


 is Active? v8.88&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Added @get_sleeping_spids option&lt;/li&gt;&lt;ul&gt;&lt;li&gt;0
 gets no sleeping SPIDs (feature requested by Alvaro Mosquera)&lt;/li&gt;&lt;li&gt;1
 (default) gets sleeping SPIDs only if they are holding an open 
transaction&lt;/li&gt;&lt;li&gt;2 gets all sleeping SPIDs (feature requested by a 
few people over the past couple of months)&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Added 
@format_output option 2, the "Aaron Bertrand" option (proper formatting 
for fixed-width fonts)&lt;br&gt;&lt;/li&gt;&lt;li&gt;Re-wrote the join condition to find 
tasks associated with requests--now using task_address rather than 
request_id&lt;/li&gt;&lt;li&gt;Fixed
a bug where MARS connections and other situations cause more rows in
the Connections DMV than I expected, which created a PK error on one of
the temp tables&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Many thanks to Michelle Ufford for reporting
 this bug!&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who is Active? v8.81&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Flipped the @get_plans
options changed in v8.75 so that 1 now gets the plan based on the
current running statement (after I tested it a bit I found that mode to
be much more useful than the other mode when using stored procedures).
2 now gets the full plan.&lt;/li&gt;&lt;li&gt;Modified the timeout code for getting
plans and query text, to better handle other errors that might occur
(now sends back an error message instead)&lt;/li&gt;&lt;li&gt;Added a link to this 
downloads section so that you can more easily find new "Beta" builds!&lt;/li&gt;&lt;/ul&gt;
&lt;br&gt;
&lt;p&gt;Who


 is Active? v8.77&lt;/p&gt;
&lt;p&gt;Fixed two bugs:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Was
casting SUM(context_switches) and SUM(physical_io) for the session into
an INT, causing an overflow problem (thanks, Sankar Reddy!)&lt;/li&gt;&lt;ul&gt;&lt;li&gt;Note


 to self: [some int value] + [some int value] may be greater than [max 
int value]&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;li&gt;Was incorrectly dividing used memory KB by 
8192 instead of 8 to get the number of used pages&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who


 is Active? v8.75 &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Added a new suboption to @get_plans:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;As
before,


 an argument value of 0 will cause plans to not be fetched, and
a value of 1 will cause plans to be fetched based on the plan_handle
associated with the request.&lt;/li&gt;&lt;li&gt;The modification is that a value
of 2 willh cause the plans to be fetched based on both the plan_handle
and the statement offsets associated with the request. &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Using
a


 value of 1--pulling the plan based only on the plan_handle--you may
see that the generated plan is the plan for the entire stored procedure
or batch currently running, and not just the statement that is
currently active. Using option 2 you may be able to get more targeted
plans, that will correspond directly to the statement you see in the
sql_text column.&lt;/p&gt;
I have not thoroughly tested this change. Please
give it a try and let me know if you see anything strange or
unexpected--in either a good way or a bad way. 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who is Active?
 v8.74 &lt;br&gt;
&lt;/p&gt;
&lt;p&gt;Further tweaks to yesterday's RUNNABLE enhancement. Fixed a bug
where the number of active tasks was miscounted in some cases. Also
renamed the "threads" column to "tasks" to be more specific about what
it is really counting.&lt;br&gt;&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;Who is Active? v8.72&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Modified wait_info to show tasks on the runnable queue. These 
will show up with wait type "RUNNABLE"&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp; &lt;br&gt;&lt;/p&gt;
&lt;p&gt;Who is 
Active? v8.71 &lt;br&gt;
&lt;/p&gt;


&lt;ul&gt;&lt;li&gt;Added program_name to default output&lt;/li&gt;&lt;li&gt;Removed @spid 
parameter, replaced with flexible filter options&lt;/li&gt;&lt;ul&gt;&lt;li&gt;@filter_type


 - allows user to specify session, database, host, login, or program&lt;/li&gt;&lt;li&gt;@filter


 - The actual text to filter; supports wildcards&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;br&gt;

&lt;p&gt;Two minor bug fixes for v8.69:&lt;/p&gt;


&lt;ol&gt;&lt;li&gt;Would fail for sessions running with ANSI_PADDING or 
QUOTED_IDENTIFIERS turned off&lt;/li&gt;&lt;li&gt;Would very rarely fail due to an 
improperly formed join to sys.dm_exec_query_memory_grants&lt;/li&gt;&lt;/ol&gt;


&lt;p&gt;Both of these should be fixed in this version.&lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Who is Active? v8.67&lt;/p&gt;


&lt;p&gt;Online help: @help = 1&lt;/p&gt;


&lt;ul&gt;&lt;li&gt;self-explanatory&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;p&gt;Find block leaders: @find_block_leaders = 1 &lt;/p&gt;


&lt;ul&gt;&lt;li&gt;Returns
a column called "blocked_session_count" that is the result of a count,
starting from each blocker and walking down the entire blocking chain.&amp;nbsp;
Each blocker will have the count of all blocked sessions down the
chain, including those that are blocked by SPIDs the blocker is blocking&lt;/li&gt;&lt;/ul&gt;


&lt;p&gt;@output_column_list supports simple wildcards&lt;/p&gt;


&lt;ul&gt;&lt;li&gt;% and _ are now allowed.&amp;nbsp; So you can do, e.g.: 
@output_column_list = '[tran%] [%]'&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Delta Force (A Month of Activity Monitoring, Part 26 of 30)</title><link>http://sqlblog.com/blogs/adam_machanic/archive/2011/04/26/delta-force-a-month-of-activity-monitoring-part-26-of-30.aspx</link><pubDate>Tue, 26 Apr 2011 14:00:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:35112</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;&lt;i&gt;This post is part 26 of a 30-part series about the &lt;a href="http://sqlblog.com/files/folders/35046/download.aspx"&gt;Who is Active&lt;/a&gt; stored procedure. A new post will run each day during the month of April, 2011. After April all of these posts will be edited and combined into a single document to become the basis of the Who is Active documentation.&lt;/i&gt;&lt;/p&gt;  &lt;hr&gt;  &lt;p&gt;The CPU is pegged. Your hard disks are fried. Memory consumption is through the roof. &lt;b&gt;Who is to blame?!?&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Well that’s easy. Blame the session with the most CPU consumption. Blame the session doing the most I/O operations. Ask Who is Active what’s going on—it’ll tell you...&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/F26_01_cpu_74325373.jpg"&gt;&lt;img src="http://sqlblog.com/blogs/adam_machanic/F26_01_cpu_thumb_7A0CF70C.jpg" style="background-image:none;border:0px none;padding-left:0px;padding-right:0px;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0px;" title="F26_01_cpu" alt="F26_01_cpu" border="0" height="84" width="365"&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;&lt;i&gt;Clearly&lt;/i&gt; session 52 is the problem here. It’s consumed over 2,000,000 milliseconds of CPU time. Session 53, on the other hand, has consumed a paltry five seconds. No brainer, right?&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Except that it’s not&lt;/b&gt;.&lt;/p&gt;  &lt;p&gt;Session 52? It’s in a wait state. (WAITFOR, to be exact.) Not consuming any CPU time at all at the time I ran Who is Active. Session 53? Using plenty. So why the discrepancy? Does Who is Active have a major bug? &lt;/p&gt;  &lt;p&gt;The fact is—and this will be obvious to a lot of you, so forgive me—most of the metrics reported by Who is Active are &lt;i&gt;cumulative&lt;/i&gt;. They’re totals from the entire session, or the entire lifetime of the request (depending on what’s going on). In the case of session 52 in the image above, that much CPU time was consumed over a five-minute period &lt;i&gt;prior&lt;/i&gt; to the point in time when I ran Who is Active. Session 53, on the other hand, is &lt;i&gt;currently&lt;/i&gt; consuming CPU time. But how do I figure that out?&lt;/p&gt;  &lt;p&gt;&lt;b&gt;The answer: delta mode.&lt;/b&gt; This feature is something for which you can thank Jimmy May, who kept telling me about his “SQL Deltoids” script that he’d written back in the bad old days of SQL Server 2000. “If only there were a way to apply that script to the SQL Server 2005 DMVs,” he lamented one day. So I added the functionality into Who is Active. It’s quite simple, and surprisingly effective.&lt;/p&gt;  &lt;p&gt;To use delta mode, simply invoke Who is Active’s &lt;i&gt;@delta_interval&lt;/i&gt; option. Setting an interval will cause the procedure to execute its main logic branch, then wait the specified amount of time—a number of seconds between 1 and 255—before running the same main logic branch again. All of the numeric values that changed during that period will be compared, and the changed numbers will be output in a series of columns named with &lt;i&gt;_delta&lt;/i&gt; at the end. &lt;/p&gt;  &lt;p&gt;For example, here are the same two sessions as above, viewed in delta mode:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @delta_interval = 5&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/F26_02_delta_79349122.jpg"&gt;&lt;img src="http://sqlblog.com/blogs/adam_machanic/F26_02_delta_thumb_062E7134.jpg" style="background-image:none;border:0px none;padding-left:0px;padding-right:0px;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0px;" title="F26_02_delta" alt="F26_02_delta" border="0" height="83" width="463"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;During the five-second delta interval, session 52 consumed no CPU time. Session 53, on the other hand, consumed over 5,000 milliseconds of time. If the CPU is pegged, 52 is no longer contributing—53 is the session of interest.&lt;/p&gt;  &lt;p&gt;Enabling delta mode will add some or all of the following columns to the output, depending on what other options have been set:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;physical_io_delta&lt;/li&gt;    &lt;li&gt;reads_delta&lt;/li&gt;    &lt;li&gt;physical_reads_delta&lt;/li&gt;    &lt;li&gt;writes_delta&lt;/li&gt;    &lt;li&gt;tempdb_allocations_delta&lt;/li&gt;    &lt;li&gt;tempdb_current_delta&lt;/li&gt;    &lt;li&gt;CPU_delta&lt;/li&gt;    &lt;li&gt;context_switches_delta&lt;/li&gt;    &lt;li&gt;used_memory_delta&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;By leveraging these delta columns in conjunction with the &lt;i&gt;@sort_order&lt;/i&gt; option, it’s easy to quickly see which sessions are &lt;i&gt;currently&lt;/i&gt; consuming your valuable server resources—which is generally more interesting than seeing which sessions may have been consuming resources but are now waiting or sleeping.&lt;/p&gt;&lt;p&gt;Note: The various sessions and requests you'll see in delta mode pertain to the information captured after the wait interval. Information about requests that were running as of the first collection but are not running as of the second is discarded. New requests that started after the first collection will be shown, but with delta values of NULL. Locks, transactions, and other optional information, will also be captured only for the second collection, since no delta calculation is possible for those metrics (at least, not yet).&lt;br&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Homework&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Delta mode, in its current form, is only really useful if you have requests that last longer than a second (at minimum—I usually do five or ten-second intervals). What kind of workload do you see on your servers? Is delta mode as it exists today something that you’re making use of (or that you’ll start making use of, now that I’ve written a post about it)?&lt;/p&gt;</description></item><item><title>Capturing the Output (A Month of Activity Monitoring, Part 25 of 30)</title><link>http://sqlblog.com/blogs/adam_machanic/archive/2011/04/25/capturing-the-output-a-month-of-activity-monitoring-part-25-of-30.aspx</link><pubDate>Mon, 25 Apr 2011 14:00:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:35111</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;&lt;i&gt;This post is part 25 of a 30-part series about the &lt;a href="http://sqlblog.com/files/folders/35240/download.aspx"&gt;Who is Active&lt;/a&gt; stored procedure. A new post will run each day during the month of April, 2011. After April all of these posts will be edited and combined into a single document to become the basis of the Who is Active documentation.&lt;/i&gt;&lt;/p&gt;  &lt;hr&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2011/04/24/the-output-of-your-dreams-a-month-of-activity-monitoring-part-24-of-30.aspx"&gt;Yesterday’s post&lt;/a&gt; was about configuring the output based on what &lt;i&gt;you&lt;/i&gt; want to see. &lt;b&gt;Today’s post is about taking that perfect output and persisting it.&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;There are many reasons that you might like to store the results of a Who is Active call to a table. Some of the real use cases that I’ve been told about by Who is Active users include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Scheduled monitoring. Capturing the results of Who is Active calls in 5 or 10 minute intervals to see what’s happening on the database server throughout the day (or night)&lt;/li&gt;    &lt;li&gt;Using it as part of a build process, to verify that the correct things are happening in the correct order at the correct times&lt;/li&gt;    &lt;li&gt;Using it as part of an exception handling system that automatically calls Who is Active every time an error occurs, to snapshot the current state of the database instance&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;And there are various other use cases in addition to these. The point is that there are a number of reasons that you might want to capture the output. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Unfortunately, it’s not as simple a task as you might think.&lt;/b&gt; The first time I tried to make it work, I did something like:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;CREATE TABLE #output       &lt;br&gt;(        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...        &lt;br&gt;)&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;INSERT #output       &lt;br&gt;EXEC sp_WhoIsActive&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This approach failed miserably. If you try it, as I did, you’ll see the following error message:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;Msg 8164, Level 16, State 1, Procedure sp_WhoIsActive, Line 3086       &lt;br&gt;An INSERT EXEC statement cannot be nested.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Who is Active uses a number of INSERT EXEC statements, and they cannot be easily changed or removed, so for a while it seemed like all was lost. After a bit of brainstorming, however, I realized that I could simply build yet another INSERT EXEC into Who is Active—one that will insert into a table of your choice.&lt;/p&gt;  &lt;p&gt;Of course, first you need a table. And if you’ve been reading this series you’re no doubt aware that the output shape returned by Who is Active is extremely dynamic in nature, and depends on which parameters are being used. So the first option I added was&lt;b&gt; a method by which you can get the output schema. &lt;/b&gt;Two parameters are involved: If &lt;i&gt;@return_schema&lt;/i&gt; is set to &lt;b&gt;1&lt;/b&gt;, the schema shape will be returned in an &lt;i&gt;OUTPUT&lt;/i&gt; parameter called &lt;i&gt;@schema&lt;/i&gt;. This is best shown by way of example:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @s VARCHAR(MAX)&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @output_column_list = '[temp%]',        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @return_schema = 1,        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @schema = @s OUTPUT&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;SELECT @s&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The idea is that you set up your Who is Active call with all of the options you’d like, then bolt on the &lt;i&gt;@return_schema&lt;/i&gt; and &lt;i&gt;@schema&lt;/i&gt; parameters. Here the column list is being restricted to only those columns having to do with &lt;i&gt;tempdb&lt;/i&gt;. If you run this code, the &lt;i&gt;SELECT&lt;/i&gt; will return the following result:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;CREATE TABLE &amp;lt;table_name&amp;gt; ( [tempdb_allocations] varchar(30) NULL,[tempdb_current] varchar(30) NULL)&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This result can be modified by replacing the “&amp;lt;table_name&amp;gt;” placeholder with the name of the table you actually want to persist the results to. Of course this can be done either manually or automatically—after the call to Who is Active, the text is sitting in a variable, so a simple call to &lt;i&gt;REPLACE&lt;/i&gt; is all that’s needed. That call could even be followed up by a call to execute the result and create the table...&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @s VARCHAR(MAX)&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @output_column_list = '[temp%]',        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @return_schema = 1,        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @schema = @s OUTPUT&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;SET @s = REPLACE(@s, '&amp;lt;table_name&amp;gt;', 'tempdb.dbo.monitoring_output')&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;EXEC(@s)&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;b&gt;Of course now you probably want to put something into the table&lt;/b&gt;. Crazy! To do this, drop the &lt;i&gt;@return_schema&lt;/i&gt; and &lt;i&gt;@schema&lt;/i&gt; parameters and replace them with &lt;i&gt;@destination_table&lt;/i&gt;—the name of the table into which the results should be inserted:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;EXEC sp_WhoIsActive     &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @output_column_list = '[temp%]',      &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @destination_table = 'tempdb.dbo.monitoring_output'&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Now the results of the call will be inserted into the destination table. Just remember that every time you change the Who is Active options, you’ll have to re-acquire the output shape. Even a small change, such as adding an additional column to the output list, will result in a catastrophic error.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @output_column_list = '[session_id][temp%]',        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @destination_table = 'tempdb.dbo.monitoring_output'&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;Msg 213, Level 16, State 1, Line 1       &lt;br&gt;Column name or number of supplied values does not match table definition.&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;b&gt;How far you take this feature depends on how creative you are&lt;/b&gt;. Some of you have come up with elaborate schemes, but I generally keep it simple. Something that I like to do is to set up a short semi-automated process by using Management Studio’s &lt;i&gt;GO [N]&lt;/i&gt; option. I use this when I’m doing intense debugging, and will do something like:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;DECLARE @s VARCHAR(MAX)&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&lt;/font&gt;&lt;font face="Courier New"&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 = @s OUTPUT&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;SET @s = REPLACE(@s, '&amp;lt;table_name&amp;gt;', 'tempdb.dbo.quick_debug')&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;EXEC(@s)       &lt;br&gt;GO&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @format_output = 0,&lt;/font&gt;        &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @destination_table = 'tempdb.dbo.quick_debug'&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font face="Courier New"&gt;WAITFOR DELAY '00:00:05'       &lt;br&gt;GO 60&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This will first create a table in &lt;i&gt;tempdb&lt;/i&gt;, after which it will collect the results every five seconds for a five-minute period. I set &lt;i&gt;@format_output&lt;/i&gt; to &lt;b&gt;0&lt;/b&gt; in order to get rid of the text formatting so that I can more easily work with the numeric data. &lt;b&gt;The results can be correlated to performance counters or other external information&lt;/b&gt; using the [collection_time] column, which was added to Who is Active specifically to support automated data collection.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Homework&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Share your experiences with Who is Active’s data collection feature. How are you using it? Have you hit any problems or roadblocks? Any awesome success stories? A few sentences will be great, and more is fine if you’re in the mood to tell a story.&lt;/p&gt;</description></item><item><title>The Output of Your Dreams (A Month of Activity Monitoring, Part 24 of 30)</title><link>http://sqlblog.com/blogs/adam_machanic/archive/2011/04/24/the-output-of-your-dreams-a-month-of-activity-monitoring-part-24-of-30.aspx</link><pubDate>Sun, 24 Apr 2011 14:00:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:35110</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;&lt;i&gt;This post is part 24 of a 30-part series about the &lt;a href="http://sqlblog.com/files/folders/35240/download.aspx"&gt;Who is Active&lt;/a&gt; stored procedure. A new post will run each day during the month of April, 2011. After April all of these posts will be edited and combined into a single document to become the basis of the Who is Active documentation.&lt;/i&gt;&lt;/p&gt;  &lt;hr&gt;  &lt;p&gt;&lt;b&gt;Early in the process of creating Who is Active it became clear that there was no way everyone was going to agree.&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;With each release I received requests to move some column so that it would show up on the lefthand side, or to change the sort order, or to make some other modification that someone felt was necessary to help them more easily digest the data. The problem: it was impossible to accommodate all of these requests. So I decided to go with a self-service model.&lt;/p&gt;  &lt;p&gt;In order to allow users to dynamically customize the output (without touching any code), the stored procedure exposes three options: &lt;i&gt;@output_column_list&lt;/i&gt;, &lt;i&gt;@sort_order&lt;/i&gt;, and &lt;i&gt;@format_output&lt;/i&gt;. Each of these is discussed in the following sections.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;@output_column_list&lt;/i&gt;&lt;/b&gt; controls not only whether or not certain columns will be shown in the output, but also the order in which the columns are displayed. The correct argument is a list of bracket-delimited column names (or partial names with wildcards). Delimiters are not necessary (use whatever delimiter you like, or none at all; they’re ignored). The key to successfully using this option is to remember that inclusion of columns in the output is additive: many columns (such as [additional_info]) are only added to the output if both the correct options are enabled for the stored procedure and the columns are included in the column list. If you start modifying the list and don’t take this into account, you may not see the columns you’re expecting when you go back later and start changing options. To keep things flexible, make sure to use wildcard columns, especially a generic wildcard (&lt;i&gt;[%]&lt;/i&gt;) at the end.&lt;/p&gt;  &lt;p&gt;Using the column list can be as simple as specifying the exact columns you’re interested in:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @output_column_list = '[tempdb_allocations][tempdb_current]'&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Notice that no delimiter is used here. Again, any extraneous text aside from the column specifiers is ignored, so the following call is equivalent:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @output_column_list = 'this[tempdb_allocations]is[tempdb_current]ignored'&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Easier than specifying exact column names is to use wildcards that match the pattern of the columns you’re interested in:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @output_column_list = '[tempdb%]'&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;All three of these calls will yield the same output, similar to the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/F24_01_column_list_0638D459.jpg"&gt;&lt;img src="http://sqlblog.com/blogs/adam_machanic/F24_01_column_list_thumb_654561B1.jpg" style="background-image:none;border:0px none;padding-left:0px;padding-right:0px;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0px;" title="F24_01_column_list" alt="F24_01_column_list" border="0" height="59" width="283"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Of course, this will return &lt;i&gt;only&lt;/i&gt; these two columns. Generally I’ll use the column list feature just to move things around so that I don’t have to do as much scrolling, and in those cases I almost always want everything else, too. That’s where the generic wildcard comes into play:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @output_column_list = '[tempdb%][%]'&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/F24_02_all_cols_5DB9F244.jpg"&gt;&lt;img src="http://sqlblog.com/blogs/adam_machanic/F24_02_all_cols_thumb_71D30ECD.jpg" style="background-image:none;border:0px none;padding-left:0px;padding-right:0px;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0px;" title="F24_02_all_cols" alt="F24_02_all_cols" border="0" height="59" width="638"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Now the &lt;i&gt;tempdb&lt;/i&gt;-specific columns appear on the lefthand side, and all of the other columns follow, in a default order.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;The next option we’ll cover is &lt;i&gt;@sort_order&lt;/i&gt;&lt;/b&gt;. This option controls the order of the rows output by the stored procedure. Like &lt;i&gt;@output_column_list&lt;/i&gt;, the input is a list of bracket-delimited column names. In this case, wildcards are not supported, but the keywords &lt;i&gt;ASC&lt;/i&gt;[ENDING] and &lt;i&gt;DESC&lt;/i&gt;[ENDING] are supported after the column name.&lt;/p&gt;  &lt;p&gt;The following call returns data sorted by [login_name] ascending (ascending is default, so the keyword is optional), with ties broken by [session_id] descending:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font face="Courier New"&gt;EXEC sp_WhoIsActive       &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @sort_order = '[login_name][session_id] DESC'&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;As before, delimiters are optional and are ignored. Please note that the current betas of Who is Active have bug where multi-column sorts like this one are not properly honored. That issue will be fixed in the next version of Who is Active. &lt;/p&gt;  &lt;p&gt;Sorting is especially useful when doing any kind of comparison of the various requests currently running. I use it extensively in block leader mode ([blocked_session_count] DESC), and it is quite handy in delta mode—which will be covered in a post in a few days.&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;The final option this post will cover is&lt;i&gt; @format_output&lt;/i&gt;.&lt;/b&gt; This one is based on the fact that Who is Active is designed to leverage SSMS as a “graphical user interface” of sorts. Query text is sent back in an XML format, numbers are formatted as right-justified strings, and elapsed time is formatted in the more easily-digestible [dd hh:mm:ss.mss] form. &lt;/p&gt;  &lt;p&gt;If you’ve been using Who is Active for a while you’ve probably noticed the right-justified numbers:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://sqlblog.com/blogs/adam_machanic/F24_03_right_justified_7819E55B.jpg"&gt;&lt;img src="http://sqlblog.com/blogs/adam_machanic/F24_03_right_justified_thumb_50736931.jpg" style="background-image:none;border:0px none;padding-left:0px;padding-right:0px;display:block;float:none;margin-left:auto;margin-right:auto;padding-top:0px;" title="F24_03_right_justified" alt="F24_03_right_justified" border="0" height="69" width="308"&gt;&lt;/a&gt;&lt;/p&gt;      &lt;p&gt;This format was suggested fairly early on by Aaron Bertrand, and is one of my favorite things about the stored procedure. It makes it much easier to pick out bigger numbers when you’re looking at a large set of data. By default, SSMS uses a non-fixed width font for grid results, so the default argument to &lt;i&gt;@format_output, &lt;/i&gt;&lt;b&gt;1&lt;/b&gt;, takes this into consideration. But some people—like Aaron Bertrand—change the SSMS settings and use a fixed width font instead. If you’re one of these people you can use an argument of &lt;b&gt;2&lt;/b&gt; to get nicely-formatted numbers. If you don’t change the argument you might notice that the numbers don’t seem to properly line up when you’re working with a set of data containing numbers of greatly differing size.&lt;/p&gt;  &lt;p&gt;Still other people don’t like the right-justified numbers or are doing collection to a table (see tomorrow's post), and so formatting can be completely disabled by using an argument of &lt;b&gt;0&lt;/b&gt;. It’s up to you...&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;Homework&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Today’s homework is to enjoy your Sunday. You’re a busy DBA; you’ve earned a break. Get outside and off of the computer!&lt;/p&gt;</description></item></channel></rss>