Day 10 – Retention of XE Session Data in a Table

This is the tenth installment in the 12 day series for SQL tidbits during this holiday season.

Previous articles in this mini-series on quick tidbits:

  1. SQL Sat LV announcement
  2. Burning Time
  3. Reviewing Peers
  4. Broken Broker
  5. Peer Identity
  6. Lost in Space
  7. Command ‘n Conquer
  8. Ring in The New
  9. Queries Going Boom



Gathering event information is a pretty good thing.  It can do wonders for helping to troubleshoot.  What do you do if you need or want to be able to review the captured information in 3 months or maybe 12 months from now?

Retaining the session data for later consumption is often a pretty essential piece of the puzzle.  There is more than one way to accomplish that goal.  I am going to share one method that may be more like a sledgehammer for some.  It does require that Management Data Warehouse be enabled prior to implementing.

When using MDW to gather and retain the session data, you create a data collector pertinent to the data being collected and retained.  In the following example, I have a data collector that is created to gather deadlock information from the system health session.  In this particular case, I query the XML in the ring buffer to get the data that I want.  Then I tell the collector to gather that info every 15 minutes.  The collection interval is one of those things that needs to be adjusted for each environment.  If you collect the info too often, you could end up with a duplication of data.  Too seldom and you could miss some event data.  It is important to understand the environment and adjust accordingly.

Here is that example.

[codesyntax lang=”tsql”]


Looking this over, there is quite a bit going on.  The keys are the following paramaters: @parameters and @interval.  The @parameters parameter stores the XML query to be used when querying the ring buffer (in this case).  It is important to note that the XML query in this case needs to ensure that the values node is capped to a max of varchar(4000) like shown in the following.

[codesyntax lang=”tsql”]


With this data collector, I have trapped information and stored it for several months so I can compare notes at a later date.

page 1 of 1

January 2014
« Dec   Feb »


  • @jonleelockwood: #sqlhelp what is the max latency for sql 2012 to think tempdb is missing? Thanks.
  • @sqL_handLe: #sqlhelp Anyone monitor ESXTop migrations/sec, switches/sec, wakeups/sec for #SQLServer on VMware? Seems like lotta guesswork with %Ready.
  • @A_Bansal: No 64 GB. So which 32 GB Mobile workstation do u recommend? #sqlhelp
  • @Lee____Cam: I've managed to drop my AG now and recovered my do but it won't allow the recreation of the AG. Looks like it's failing at the FCM #sqlhelp
  • @Lee____Cam: I have a 2 note always on ag, both showing not synchronizing/recovery pending. I can't get them online or remove the AG. Any ideas #sqlhelp
  • @SQLSoldier: @mvelic Yes, but then I pointed out that they were using nolock and SSIS isn't. The matching records were not committed. #sqlhelp #TrueStory
  • @mvelic: It's just maddening because this lookup has *always* worked in the past. It's just now deciding to not recognize matches. #sqlhelp
  • @mvelic: Has anyone just seen an SSIS Lookup fail to make matches? You know the matches exist, but it doesn't connect them and it fails? #sqlhelp
  • @banerjeeamit: @MattPgh No. Current processing report is not visible. This is visible in RunningJobs table but not the stats breakdown. #sqlhelp
  • @forhakim: #sqlhelp in Visual Studio SSDT is there a way to make it NOT show table designer, only the script, when I edit a table?

Welcome , today is Saturday, October 10, 2015