﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2012 / SQL Server 2012 -  T-SQL  / Better Way of XQuerying / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Wed, 22 May 2013 04:04:49 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>[quote][b]Jeff Moden (2/22/2013)[/b][hr]Admittedly and ironically, the good things that I've seen come out of it is 1) the manufacturers of PC hardware and all that connects them together have had to make everything bigger (capability wise) yet more compact and much faster to handle the tag-bloat and parsing requirements and 2) the world has finally agreed on something even if I think it's crud. ;-)[/quote]:-D</description><pubDate>Mon, 25 Feb 2013 10:30:43 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>I'm still absolutely amazed that HTML and XML ever made it out of the starting blocks.  Both are horribly tag-bloated which unnecessarily clogs the pipe, bottlenecks I/O, and uses unnecessary amounts of memory and disk space.  They require de-entitization of some fairly common characters, require comparatively a lot of cpu time to shred or create, XML requires prior structural knowledge to parse it in T-SQL (which is VERY contrary to what it was initially advertised to do), is a whole lot less human readable than I ever expected especially for the more deeply nested stuff, and requires at least 2 different parsing techniques for "combination" XML (Element and Entity combined).I realize that both HTML and XML have worldwide acceptance and have become the defacto standard for digital communications between computers but, just because a couple of billion people are all doing the same thing, I don't have to like it especially since I think they're doing it wrong. :-PAdmittedly and ironically, the good things that I've seen come out of it is 1) the manufacturers of PC hardware and all that connects them together have had to make everything bigger (capability wise) yet more compact and much faster to handle the tag-bloat and parsing requirements and 2) the world has finally agreed on something even if I think it's crud. ;-)</description><pubDate>Fri, 22 Feb 2013 20:15:39 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>[quote][b]Jeff Moden (2/22/2013)[/b][hr][quote][b]Grant Fritchey (2/22/2013)[/b][hr]Instead of running XML queries against the server, a relatively high process event, I'd output the Extended Events to a file, then you can read that file from another server and never impact your production machine in any way. That approach makes a lot more sense to me.[/quote]I've been up to my eyes with work and they only have SQL Server 2005 so I haven't even broken the surface on Extended Events.  That explains my apparent shock and mortification when I say "REALLY!!!!  They screwed EE up with XML???" :sick:[/quote]Yes XML - just like just about everything else in SQL Server these days.  Think about everything that is XML based now in SQL Server.And just for FYI - it is XE (yeah I know, but maybe they felt EE was already too well associated to Enterprise Edition).;-)</description><pubDate>Fri, 22 Feb 2013 17:00:51 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>Looking at this quickly, I have two observations.1.  I'd look at dumping this to a file as Grant suggested.  That can be very useful - it depends.  I have to think more on what you are trying to achieve and tinker with your code.2.  You may want to setup an MDW with a Data Collector and pull the info you are seeking out of the ring buffer and store it in a normalized fashion within a database.  IMHO this can be useful for historical research and to more easily manipulate the data.I know I said two, but I am curious if you have considered using a histogram target (looks like you are trying this in 2012).  If I understand the basic needs - this could be a useful output.Lastly, to make sure I am understanding correctly as I set out to test, could you provide some semblance of how you want the data to be represented?</description><pubDate>Fri, 22 Feb 2013 16:58:53 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>[quote][b]Jeff Moden (2/22/2013)[/b][hr]I've been up to my eyes with work and they only have SQL Server 2005 so I haven't even broken the surface on Extended Events.  That explains my apparent shock and mortification when I say "REALLY!!!!  They screwed EE up with XML???" :sick:[/quote]Ha! The output is XML, yes. But, you have options to avoid it. There's the Data Explorer in 2012 that lets you just look at the output from the buffer or open files, no XML required. There is also a way to query the files directly through an extended stored procedure, again, avoiding XML.However, if you want direct, raw access to the data, yep, it's XML. Personally, I'm OK with that.</description><pubDate>Fri, 22 Feb 2013 13:54:42 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>[quote][b]Grant Fritchey (2/22/2013)[/b][hr]Instead of running XML queries against the server, a relatively high process event, I'd output the Extended Events to a file, then you can read that file from another server and never impact your production machine in any way. That approach makes a lot more sense to me.[/quote]I've been up to my eyes with work and they only have SQL Server 2005 so I haven't even broken the surface on Extended Events.  That explains my apparent shock and mortification when I say "REALLY!!!!  They screwed EE up with XML???" :sick:</description><pubDate>Fri, 22 Feb 2013 13:49:58 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>Instead of running XML queries against the server, a relatively high process event, I'd output the Extended Events to a file, then you can read that file from another server and never impact your production machine in any way. That approach makes a lot more sense to me.</description><pubDate>Fri, 22 Feb 2013 13:37:48 GMT</pubDate><dc:creator>Grant Fritchey</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>Sorry Jagan, I haven't done much work with Extended Events myself, so I'm not sure I can help you much there.  I've put out a request to some others to check in on this and see if they can offer some wisdom.</description><pubDate>Fri, 22 Feb 2013 12:18:16 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>Hello, Thank you so much for responding for my thread.  I am going to share my thoughts here out loud so that someone can guide me in the right direction. To start with, This is what I wrote. Trick is the CROSS APPLY.[code="sql"]DECLARE @xml XMLSELECT  @xml = CAST(dt.target_data AS XML)FROM    sys.dm_xe_session_targets dt        JOIN sys.dm_xe_sessions ds ON ds.Address = dt.event_session_address        JOIN sys.server_event_sessions ss ON ds.Name = ss.NameWHERE   dt.target_name = 'ring_buffer'        AND ds.Name = 'EE_LongRunningQueries'SELECTEvents.Info.value('@name', 'VARCHAR(MAX)'),Events.Info.value('@timestamp', 'DATETIME'),Datas.ChildInfo.value('@name', 'VARCHAR(MAX)'),Datas.ChildInfo.value('value[1]','VARCHAR(MAX)')FROM @xml.nodes('/RingBufferTarget/event') AS Events(Info)CROSS APPLY Events.Info.nodes('*') AS Datas(childInfo)[/code]If you have any better thoughts, please share with me. Reading few blogs online on EEs made me realize how power EE is. I want to use it more extensively for monitoring. Currently, EE in my hand is like tool with a fool.[b]Driving the discussion further X-query - [/b]I want to add some more information so that you can guide me. [b]What we have today:[/b]we query exec_requests and sessions and get the list of queries running in our system every 1 minute. If anything is running more than 1 minute, we will alert ourselves and get hold of developer to fix the code or add indexes. We also have a config table to exclude certain legacy stuff and maintenance jobs.[b]What we want to do:[/b]Firstly, I want to know, if our current monitoring system for the sqls running in our system is good or not. Also, we want to use extended events(EE) to monitor our system. the vision I have in my mind is to grab everything that is running on the system through EE, and have a job to wake up every minute look back 1 minute based on timestamp and alert us if there is no sql_statement_completed event is not associated with that session id. This way, I know I am not missing any queries within that 1 minute &amp;#119;indow. Please let me know if my vision is in the correct path.Also, I want to know, what else, I can do with EEs. I have plans of collecting dead lock reports. logical drive counters(I know Johnathan has a ticket opened for this. waiting for that ticket to be addressed.)Please help the fool to use the tool!</description><pubDate>Thu, 21 Feb 2013 18:20:39 GMT</pubDate><dc:creator>jvkondapalli</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>Hello, Thank you so much for responding for my thread.  I am going to share my thoughts here out loud so that someone can guide me in the right direction. To start with, This is what I wrote. Trick is the CROSS APPLY.[code="sql"]DECLARE @xml XMLSELECT  @xml = CAST(dt.target_data AS XML)FROM    sys.dm_xe_session_targets dt        JOIN sys.dm_xe_sessions ds ON ds.Address = dt.event_session_address        JOIN sys.server_event_sessions ss ON ds.Name = ss.NameWHERE   dt.target_name = 'ring_buffer'        AND ds.Name = 'EE_LongRunningQueries'SELECTEvents.Info.value('@name', 'VARCHAR(MAX)'),Events.Info.value('@timestamp', 'DATETIME'),Datas.ChildInfo.value('@name', 'VARCHAR(MAX)'),Datas.ChildInfo.value('value[1]','VARCHAR(MAX)')FROM @xml.nodes('/RingBufferTarget/event') AS Events(Info)CROSS APPLY Events.Info.nodes('*') AS Datas(childInfo)[/code]If you have any better thoughts, please share with me. Reading few blogs online on EEs made me realize how power EE is. I want to use it more extensively for monitoring. Currently, EE in my hand is like tool with a fool.[b]Driving the discussion further X-query - [/b]I want to add some more information so that you can guide me. [b]What we have today:[/b]we query exec_requests and sessions and get the list of queries running in our system every 1 minute. If anything is running more than 1 minute, we will alert ourselves and get hold of developer to fix the code or add indexes. We also have a config table to exclude certain legacy stuff and maintenance jobs.[b]What we want to do:[/b]Firstly, I want to know, if our current monitoring system for the sqls running in our system is good or not. Also, we want to use extended events(EE) to monitor our system. the vision I have in my mind is to grab everything that is running on the system through EE, and have a job to wake up every minute look back 1 minute based on timestamp and alert us if there is no sql_statement_completed event is not associated with that session id. This way, I know I am not missing any queries within that 1 minute &amp;#119;indow. Please let me know if my vision is in the correct path.Also, I want to know, what else, I can do with EEs. I have plans of collecting dead lock reports. logical drive counters(I know Johnathan has a ticket opened for this. waiting for that ticket to be addressed.)Please help the fool to use the tool!</description><pubDate>Thu, 21 Feb 2013 17:36:48 GMT</pubDate><dc:creator>jvkondapalli</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>JV are you still having difficulties with this, before I spend some time on it?</description><pubDate>Thu, 21 Feb 2013 16:24:12 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>The short form is that you have to work from the ringbuffertarget\event node for your counts, which you're doing, but then join to another table or XMLdata.node that's deeper to apply the data in a flatter form, so you can query to the right information.You have to end up normalizing it by calling different nodes simultaneously.However, it's 1AM here and XQuery is enough to give me fits when I'm wide awake.  I know where you're trying to go conceptually but my brain isn't putting the pieces together right.  I'll try to come back tomorrow to check up on this thread if my world doesn't asplode with a recent rollout's fallout.</description><pubDate>Wed, 20 Feb 2013 01:29:07 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>RE: Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>Can one of the gurus help me please...:crying:</description><pubDate>Tue, 19 Feb 2013 17:40:47 GMT</pubDate><dc:creator>jvkondapalli</dc:creator></item><item><title>Better Way of XQuerying</title><link>http://www.sqlservercentral.com/Forums/Topic1421470-3077-1.aspx</link><description>Gurus, I am very new to XQuery. Trying to figure out how I can make use of extended events to monitor long running queries in my system.I know, I am not thinking straight and pretty sure there must be a better way of doing this. So, I am here to seek your help. Please help. Below are the XML and SQL Code that I started. Basically, my ultimate goal is to get eventname, timestamp, dataname, data value, data type name, action name, action value in the same select result set. Please help.[code="xml"]&amp;lt;RingBufferTarget truncated="0" processingTime="0" totalEventsProcessed="77" eventCount="77" droppedCount="0" memoryUsed="227166"&amp;gt;  &amp;lt;event name="sql_statement_starting" package="sqlserver" timestamp="2013-02-19T02:55:08.072Z"&amp;gt;    &amp;lt;data name="state"&amp;gt;      &amp;lt;type name="statement_starting_state" package="sqlserver" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;      &amp;lt;text&amp;gt;Normal&amp;lt;/text&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;data name="line_number"&amp;gt;      &amp;lt;type name="int32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;1&amp;lt;/value&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;data name="offset"&amp;gt;      &amp;lt;type name="int32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;data name="offset_end"&amp;gt;      &amp;lt;type name="int32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;-1&amp;lt;/value&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;data name="statement"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;USE [master]&amp;lt;/value&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;action name="username" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;LEGALZOOM\jvkondapalli&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="tsql_stack" package="sqlserver"&amp;gt;      &amp;lt;type name="xml" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;        &amp;lt;frames&amp;gt;          &amp;lt;frame level="1" handle="0x010001005307591E009CA8D90200000000000000000000000000000000000000000000000000000000000000" line="1" offsetStart="0" offsetEnd="-1" /&amp;gt;        &amp;lt;/frames&amp;gt;      &amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="tsql_frame" package="sqlserver"&amp;gt;      &amp;lt;type name="xml" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;        &amp;lt;frame level="0" handle="0x010001005307591E009CA8D90200000000000000000000000000000000000000000000000000000000000000" line="1" offsetStart="0" offsetEnd="-1" /&amp;gt;      &amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="transaction_sequence" package="sqlserver"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="transaction_id" package="sqlserver"&amp;gt;      &amp;lt;type name="int64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="sql_text" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;USE [master]&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="session_resource_group_id" package="sqlserver"&amp;gt;      &amp;lt;type name="uint32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;2&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="session_nt_username" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;LEGALZOOM\jvkondapalli&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="session_id" package="sqlserver"&amp;gt;      &amp;lt;type name="uint16" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;55&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="server_instance_name" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;GIT3JVKONDA&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="query_plan_hash" package="sqlserver"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="query_hash" package="sqlserver"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="plan_handle" package="sqlserver"&amp;gt;      &amp;lt;type name="binary_data" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;060001005307591e40bdaad90200000001000000000000000000000000000000000000000000000000000000&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="is_system" package="sqlserver"&amp;gt;      &amp;lt;type name="boolean" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="database_name" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;master&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="database_id" package="sqlserver"&amp;gt;      &amp;lt;type name="uint16" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;1&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="client_hostname" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;GIT3JVKONDA&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="client_app_name" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;Microsoft SQL Server Management Studio&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="task_time" package="sqlos"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;15969513&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="task_elapsed_quantum" package="sqlos"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="task_address" package="sqlos"&amp;gt;      &amp;lt;type name="ptr" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0x00000002e4013868&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="scheduler_id" package="sqlos"&amp;gt;      &amp;lt;type name="uint32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="scheduler_address" package="sqlos"&amp;gt;      &amp;lt;type name="ptr" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0x00000002e4140040&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="cpu_id" package="sqlos"&amp;gt;      &amp;lt;type name="uint32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="last_error" package="package0"&amp;gt;      &amp;lt;type name="uint32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="event_sequence" package="package0"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;1&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="collect_system_time" package="package0"&amp;gt;      &amp;lt;type name="filetime" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;2013-02-19T02:55:08.072Z&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="collect_cpu_cycle_time" package="package0"&amp;gt;      &amp;lt;type name="cpu_cycle" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;978307646018484&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;  &amp;lt;/event&amp;gt;  &amp;lt;event name="sql_statement_starting" package="sqlserver" timestamp="2013-02-19T02:55:14.686Z"&amp;gt;    &amp;lt;data name="state"&amp;gt;      &amp;lt;type name="statement_starting_state" package="sqlserver" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;      &amp;lt;text&amp;gt;Normal&amp;lt;/text&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;data name="line_number"&amp;gt;      &amp;lt;type name="int32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;1&amp;lt;/value&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;data name="offset"&amp;gt;      &amp;lt;type name="int32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;data name="offset_end"&amp;gt;      &amp;lt;type name="int32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;-1&amp;lt;/value&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;data name="statement"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;SELECTdtb.name AS [Name],dtb.database_id AS [ID]FROMmaster.sys.databases AS dtbORDER BY[Name] ASC&amp;lt;/value&amp;gt;    &amp;lt;/data&amp;gt;    &amp;lt;action name="username" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;LEGALZOOM\jvkondapalli&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="tsql_stack" package="sqlserver"&amp;gt;      &amp;lt;type name="xml" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;        &amp;lt;frames&amp;gt;          &amp;lt;frame level="1" handle="0x02000000C382AC2696F6952BF2E6CE3813C6B794735D856C0000000000000000000000000000000000000000" line="1" offsetStart="0" offsetEnd="-1" /&amp;gt;        &amp;lt;/frames&amp;gt;      &amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="tsql_frame" package="sqlserver"&amp;gt;      &amp;lt;type name="xml" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;        &amp;lt;frame level="0" handle="0x02000000C382AC2696F6952BF2E6CE3813C6B794735D856C0000000000000000000000000000000000000000" line="1" offsetStart="0" offsetEnd="-1" /&amp;gt;      &amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="transaction_sequence" package="sqlserver"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="transaction_id" package="sqlserver"&amp;gt;      &amp;lt;type name="int64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="sql_text" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;SELECTdtb.name AS [Name],dtb.database_id AS [ID]FROMmaster.sys.databases AS dtbORDER BY[Name] ASC&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="session_resource_group_id" package="sqlserver"&amp;gt;      &amp;lt;type name="uint32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;2&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="session_nt_username" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;LEGALZOOM\jvkondapalli&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="session_id" package="sqlserver"&amp;gt;      &amp;lt;type name="uint16" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;57&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="server_instance_name" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;GIT3JVKONDA&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="query_plan_hash" package="sqlserver"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;9240582280910057056&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="query_hash" package="sqlserver"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;2744306676576674402&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="plan_handle" package="sqlserver"&amp;gt;      &amp;lt;type name="binary_data" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;06000100c382ac2630d31cd80200000001000000000000000000000000000000000000000000000000000000&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="is_system" package="sqlserver"&amp;gt;      &amp;lt;type name="boolean" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="database_name" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;master&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="database_id" package="sqlserver"&amp;gt;      &amp;lt;type name="uint16" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;1&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="client_hostname" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;GIT3JVKONDA&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="client_app_name" package="sqlserver"&amp;gt;      &amp;lt;type name="unicode_string" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;Microsoft SQL Server Management Studio - Transact-SQL IntelliSense&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="task_time" package="sqlos"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;2697572&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="task_elapsed_quantum" package="sqlos"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="task_address" package="sqlos"&amp;gt;      &amp;lt;type name="ptr" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0x00000002e401d498&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="scheduler_id" package="sqlos"&amp;gt;      &amp;lt;type name="uint32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;1&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="scheduler_address" package="sqlos"&amp;gt;      &amp;lt;type name="ptr" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0x00000002e4160040&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="cpu_id" package="sqlos"&amp;gt;      &amp;lt;type name="uint32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;1&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="last_error" package="package0"&amp;gt;      &amp;lt;type name="uint32" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;0&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="event_sequence" package="package0"&amp;gt;      &amp;lt;type name="uint64" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;2&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="collect_system_time" package="package0"&amp;gt;      &amp;lt;type name="filetime" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;2013-02-19T02:55:14.686Z&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;    &amp;lt;action name="collect_cpu_cycle_time" package="package0"&amp;gt;      &amp;lt;type name="cpu_cycle" package="package0" /&amp;gt;      &amp;lt;value&amp;gt;978324800911629&amp;lt;/value&amp;gt;    &amp;lt;/action&amp;gt;  &amp;lt;/event&amp;gt; &amp;lt;/RingBufferTarget&amp;gt;[/code][code="sql"]-- Idea is to check How many events are there in the .xel file. -- Iterate through the event to grab what I want. -- When I look at my half completed code, makes me feel like, -- I am not using set theory here. I hate using loops when set theory can be applied.DECLARE @xmlTable TABLE  (XMLDATA XML)INSERT INTO @xmlTableSELECT  CAST(dt.target_data AS XML)FROM    sys.dm_xe_session_targets dt        JOIN sys.dm_xe_sessions ds ON ds.Address = dt.event_session_address        JOIN sys.server_event_sessions ss ON ds.Name = ss.NameWHERE   dt.target_name = 'ring_buffer'        AND ds.Name = 'EE_LongRunningQueries'DECLARE @EventData TABLE (ID INT IDENTITY(1,1) ,Eventname VARCHAR(MAX), RecordTime DATETIME)INSERT INTO @EventDataSELECT  d.x.value('(@name)[1]', 'VARCHAR(MAX)') AS EventName ,        d.x.value('(@timestamp)[1]', 'DATETIME') AS RecordTimeFROM    @xmlTable        CROSS APPLY XMLdata.nodes('//RingBufferTarget/event') AS d ( x )DECLARE @EventCount INT	,	@LogID INT	,	@TimeStamp DATETIME  SELECT @EventCount = COUNT(*) FROM @EventDataWHILE (@EventCount &amp;gt;0)BEGIN	SELECT TOP 1 @LogID = ID, @TimeStamp = RecordTime FROM @EventData		-- select the count of the nodes in the current event	-- run a while loop to get the data inserted to a table		-- you might have to use the count of nodes to acheive this	-- decrement the EventCount variableEND[/code]</description><pubDate>Tue, 19 Feb 2013 01:37:43 GMT</pubDate><dc:creator>jvkondapalli</dc:creator></item></channel></rss>