1
kudos
spam Kudos Remove

SQL SERVER – Get Latest SQL Query for Sessions – DMV « Journey to SQL Authority with Pinal Dave

published 635 days, 4 hours, 3 minutes ago posted by pinaldavepinaldave 643 days, 12 hours, 52 minutes ago
Friday, May 14, 2010 9:36:43 AM GMT Thursday, May 06, 2010 12:48:27 AM GMT

In recent SQL Training I was asked, how can one figure out what was the last SQL Statement executed in sessions. The query for this is very simple. It uses two DMVs and created following quick script for the same. SELECT session_id, TEXT

FROM sys.dmexecconnections CROSS APPLY sys.dmexecsqltext(mostrecentsqlhandle) AS ST While working with DMVs if you ever find any DMV has column with name sqlhandle you can right away join that DMV with another DMV sys.dmexecsqltext and can get the tex...

category: Community | clicked: 0 | | source: blog.sqlauthority.com | show counter code
tags: pinaldave, SQL, SQLAuthority, SQLServer

No comments yet, be the first one to post comment.

To post your comment please login or signup