<?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 'Extended Events' and 'code generator'</title><link>http://sqlblog.com/search/SearchResults.aspx?o=DateDescending&amp;tag=Extended+Events,code+generator&amp;orTags=0</link><description>Search results matching tags 'Extended Events' and 'code generator'</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Extended Events Code Generator v1.001 - A Quick Fix</title><link>http://sqlblog.com/blogs/adam_machanic/archive/2010/05/08/extended-events-code-generator-v1-001-a-quick-fix.aspx</link><pubDate>Sat, 08 May 2010 23:23:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:24951</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;If you're one of the estimated 3-5 people who've downloaded and are using my &lt;a href="http://sqlblog.com/blogs/adam_machanic/archive/2009/07/30/introducing-extended-events-code-generator-v1-0.aspx"&gt;XE Code Generator&lt;/a&gt;, please note that version 1.000 has a small bug: text data (such as query text) larger than 8000 bytes is truncated. I've fixed this issue and am pleased to present version 1.001, attached to this post.&lt;/p&gt;&lt;p&gt;Enjoy, and stay tuned for slightly more interesting enhancements! &lt;br&gt;&lt;/p&gt;</description></item><item><title>Introducing: Extended Events Code Generator v1.0</title><link>http://sqlblog.com/blogs/adam_machanic/archive/2009/07/30/introducing-extended-events-code-generator-v1-0.aspx</link><pubDate>Thu, 30 Jul 2009 19:16:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:15621</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;SQL Server 2008 Extended Events. It's a high-performance, feature-rich, and extremely useful tracing system. Too bad &lt;b&gt;it's so difficult to figure out how to use it&lt;/b&gt;! Or is it?&lt;/p&gt;&lt;p&gt;Earlier this week &lt;a href="http://sqlblog.com/blogs/jonathan_kehayias/archive/2009/07/29/extended-events-manager-update-now-a-ssms-addin.aspx"&gt;Jonathan Kehayias announced his SSMS addin for Extended Events&lt;/a&gt;, which makes it &lt;b&gt;super-easy to create and manage events&lt;/b&gt;, and even view the raw event data. It's all done via a simple UI, so if you don't have time to learn how to do all of that stuff with the Extended Events DML and DMVs, no worries.&amp;nbsp;&lt;/p&gt;&lt;p&gt;But what if you have your event all set up thanks to Jonathan's addin, and you find that &lt;b&gt;simply viewing the data isn't enough&lt;/b&gt;--now you want to query it, and actually do some analysis. Crazy idea, isn't it? Now you're stuck, unless you want to learn how to do that XQuery stuff. Or are you?&lt;/p&gt;&lt;p&gt;Extended Events Code Generator is my solution to this second problem. Here's how it works: You install the Code Generator, which is simply a T-SQL UDF (with an optional SQLCLR component--more on that later). Then you set up your Event Session(s), with or without the help of Jonathan's addin. And &lt;b&gt;when you're ready to query, you ask the Code Generator to write some code for you&lt;/b&gt;. It sets you up with a fully-pivoted view of the data, with all of the columns cast to the appropriate T-SQL data types. Now all you have to do is code. And you'll even get the benefit of full Intellisense support, because you're just dealing with columns in a derived table, not XML.&lt;/p&gt;&lt;p&gt;In addition to making querying a breeze, &lt;b&gt;the generated code will also make a lot of Extended Events queries faster&lt;/b&gt;. I sat down with &lt;a href="http://sqlblog.com/blogs/michael_rys/"&gt;Michael Rys&lt;/a&gt;--Mr. SQLXML himself--at TechEd, and he was kind enough to spend a few hours helping me tune the generated code to make it as fast as it can possibly be. And while that's relatively fast (much faster, thanks to Michael's help, than my previous attempts), I wanted it to go even faster, so I created a SQLCLR helper function, included in the attached script, that improves performance by a factor of 3-5 on top of what Michael helped me achieve.&lt;/p&gt;&lt;p&gt;Attached to this post you will find the XE Code Generator, and at the bottom of the script--commented out for those of you who are too paranoid to run SQLCLR code--is the optional helper function. Install the Code Generator in a database of your choice (I recommend tempdb), and if you feel like it and will be using asynchronous file targets, install the SQLCLR function too. The Code Generator will automatically generate code to take advantage of the SQLCLR function if it's installed, or will generate native SQLXML code otherwise. The choice is yours.&lt;/p&gt;&lt;p&gt;Set up an Extended Events session or two, capture some data, and go crazy. I think you'll find that it's not only quite powerful but also a lot of fun to work with. So much fun, in fact, that &lt;a href="http://summit2009.sqlpass.org/Agenda/SpotlightSessions/SQLServer2008ExtendedEventsPerformanceProfi.aspx"&gt;I'm doing a session on the topic at the PASS conference&lt;/a&gt; this November, where I'll share many of the interesting use cases I've found for it to date. And of course all of the examples will use code generated by the Code Generator.&lt;/p&gt;&lt;p&gt;Feel free to reply here with questions, comments, or feature requests. And as always, enjoy! &lt;br&gt;&lt;/p&gt;</description></item></channel></rss>