<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; 2008 &#8211; 2005 &#8211; Find Longest Running Query &#8211; TSQL</title>
	<atom:link href="http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: sadinesh12@gmail.com</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-453607</link>
		<dc:creator><![CDATA[sadinesh12@gmail.com]]></dc:creator>
		<pubDate>Thu, 11 Apr 2013 06:16:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-453607</guid>
		<description><![CDATA[Simply Great talaivaa]]></description>
		<content:encoded><![CDATA[<p>Simply Great talaivaa</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vikram</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-418559</link>
		<dc:creator><![CDATA[vikram]]></dc:creator>
		<pubDate>Wed, 06 Feb 2013 11:50:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-418559</guid>
		<description><![CDATA[i tried with this query it is working great]]></description>
		<content:encoded><![CDATA[<p>i tried with this query it is working great</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #010 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-403894</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #010 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 05 Jan 2013 01:31:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-403894</guid>
		<description><![CDATA[[...] Find Longest Running Query – TSQL  [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Find Longest Running Query – TSQL  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lucky</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-383746</link>
		<dc:creator><![CDATA[Lucky]]></dc:creator>
		<pubDate>Fri, 30 Nov 2012 07:35:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-383746</guid>
		<description><![CDATA[Pinal,

I have used begin transaction in stored procedure that sp used about 1500 To 2000 times in one day for insert the record in 4 tables and fired the some triggers on two tables then updates the 3 to 4 tables records.some time my transaction come in sleeping mode. then i kill the transaction then insert the record.Plz tell the sol.]]></description>
		<content:encoded><![CDATA[<p>Pinal,</p>
<p>I have used begin transaction in stored procedure that sp used about 1500 To 2000 times in one day for insert the record in 4 tables and fired the some triggers on two tables then updates the 3 to 4 tables records.some time my transaction come in sleeping mode. then i kill the transaction then insert the record.Plz tell the sol.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: babloo</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-374313</link>
		<dc:creator><![CDATA[babloo]]></dc:creator>
		<pubDate>Thu, 15 Nov 2012 03:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-374313</guid>
		<description><![CDATA[This query is not right ...  Cannot do a cross apply of sys.sysprocesses to sys.dm_exec_query_stats . so you need to take out the first cross apply and the corresponding entries for sys.sysprocesses in the select stmt ( i.e a.spid, a.blocked .... a.loginname)]]></description>
		<content:encoded><![CDATA[<p>This query is not right &#8230;  Cannot do a cross apply of sys.sysprocesses to sys.dm_exec_query_stats . so you need to take out the first cross apply and the corresponding entries for sys.sysprocesses in the select stmt ( i.e a.spid, a.blocked &#8230;. a.loginname)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MalliReddy</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-367000</link>
		<dc:creator><![CDATA[MalliReddy]]></dc:creator>
		<pubDate>Wed, 31 Oct 2012 11:54:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-367000</guid>
		<description><![CDATA[Hi Any one please help for top 10 long running Queries for 24 hrs in one Instance.]]></description>
		<content:encoded><![CDATA[<p>Hi Any one please help for top 10 long running Queries for 24 hrs in one Instance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rohit Paliwal</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-277256</link>
		<dc:creator><![CDATA[Rohit Paliwal]]></dc:creator>
		<pubDate>Wed, 18 Apr 2012 11:57:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-277256</guid>
		<description><![CDATA[It seems it doesn’t work on 2005 :(]]></description>
		<content:encoded><![CDATA[<p>It seems it doesn’t work on 2005 :(</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQLDBA</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-271316</link>
		<dc:creator><![CDATA[SQLDBA]]></dc:creator>
		<pubDate>Tue, 03 Apr 2012 13:35:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-271316</guid>
		<description><![CDATA[SQLDBA

Hi team can anyone confirm if we can get database name as well along with top 10 long running quries.]]></description>
		<content:encoded><![CDATA[<p>SQLDBA</p>
<p>Hi team can anyone confirm if we can get database name as well along with top 10 long running quries.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nagavara</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-270808</link>
		<dc:creator><![CDATA[nagavara]]></dc:creator>
		<pubDate>Mon, 02 Apr 2012 11:42:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-270808</guid>
		<description><![CDATA[HI Someone,

Thanks for posting the query.I tried your query, it looks fine but takes a bit more time to execute the statement. Am not good into developing, is there any way to may this statement run quickly? Thanks for your post. it indeed helpful.]]></description>
		<content:encoded><![CDATA[<p>HI Someone,</p>
<p>Thanks for posting the query.I tried your query, it looks fine but takes a bit more time to execute the statement. Am not good into developing, is there any way to may this statement run quickly? Thanks for your post. it indeed helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Someone</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-257186</link>
		<dc:creator><![CDATA[Someone]]></dc:creator>
		<pubDate>Mon, 27 Feb 2012 09:27:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-257186</guid>
		<description><![CDATA[SELECT t.TEXT AS sqlstatement,
       s.execution_count AS ExecutionCount,
       s.max_elapsed_time AS MaxElapsedTime,
       s.creation_time AS LogCreatedOn,
       Datediff(MINUTE, a.last_batch, Getdate()) RunningTime,
       a.spid,
       a.blocked,
       a.waittime,
       Db_name(a.dbid) AS dbname,
       a.last_batch,
       a.hostname,
       a.program_name,
       a.nt_username,
       a.loginame
FROM   sys.dm_exec_query_stats s
       CROSS APPLY sys.sysprocesses A
       CROSS APPLY sys.Dm_exec_sql_text(s.sql_handle) t
ORDER  BY s.max_elapsed_time DESC,
          ExecutionCount DESC]]></description>
		<content:encoded><![CDATA[<p>SELECT t.TEXT AS sqlstatement,<br />
       s.execution_count AS ExecutionCount,<br />
       s.max_elapsed_time AS MaxElapsedTime,<br />
       s.creation_time AS LogCreatedOn,<br />
       Datediff(MINUTE, a.last_batch, Getdate()) RunningTime,<br />
       a.spid,<br />
       a.blocked,<br />
       a.waittime,<br />
       Db_name(a.dbid) AS dbname,<br />
       a.last_batch,<br />
       a.hostname,<br />
       a.program_name,<br />
       a.nt_username,<br />
       a.loginame<br />
FROM   sys.dm_exec_query_stats s<br />
       CROSS APPLY sys.sysprocesses A<br />
       CROSS APPLY sys.Dm_exec_sql_text(s.sql_handle) t<br />
ORDER  BY s.max_elapsed_time DESC,<br />
          ExecutionCount DESC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tejpreet</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-250632</link>
		<dc:creator><![CDATA[Tejpreet]]></dc:creator>
		<pubDate>Thu, 09 Feb 2012 17:56:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-250632</guid>
		<description><![CDATA[Is there any query where we can see longest running queries since last restart server..... Thanks in advance]]></description>
		<content:encoded><![CDATA[<p>Is there any query where we can see longest running queries since last restart server&#8230;.. Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-246547</link>
		<dc:creator><![CDATA[Andy]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 09:30:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-246547</guid>
		<description><![CDATA[Correction, they are written in T-SQL for Microsoft SQL Server.  (Not, as stated &quot;Written for MIcrosoft T-SQL Server&quot;).
However the fact remains that the sys DMV&#039;s are not present in Oracle.
I suggest starting with the v$sqlstats view (in Oracle) and trying to figure out what you need from there.]]></description>
		<content:encoded><![CDATA[<p>Correction, they are written in T-SQL for Microsoft SQL Server.  (Not, as stated &#8220;Written for MIcrosoft T-SQL Server&#8221;).<br />
However the fact remains that the sys DMV&#8217;s are not present in Oracle.<br />
I suggest starting with the v$sqlstats view (in Oracle) and trying to figure out what you need from there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-246541</link>
		<dc:creator><![CDATA[Andy]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 09:26:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-246541</guid>
		<description><![CDATA[Hi,  I think that your problem is that these queries are written for Microsoft T-SQL Server, so they will be different syntax to PL/SQL.
Oracle doesnt have the same system DMV&#039;s that SQL has, which is probably what your problem is.]]></description>
		<content:encoded><![CDATA[<p>Hi,  I think that your problem is that these queries are written for Microsoft T-SQL Server, so they will be different syntax to PL/SQL.<br />
Oracle doesnt have the same system DMV&#8217;s that SQL has, which is probably what your problem is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: harish</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-246491</link>
		<dc:creator><![CDATA[harish]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 07:51:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-246491</guid>
		<description><![CDATA[HI all,

My requirements are:-

1) How many queries are hitting database
2) What are the queries
3) Which queries is taking long time to execute.

I m using database oracle. Please help.

I tried all queries mentioned above but none of them is working :(

Thanks in advance.]]></description>
		<content:encoded><![CDATA[<p>HI all,</p>
<p>My requirements are:-</p>
<p>1) How many queries are hitting database<br />
2) What are the queries<br />
3) Which queries is taking long time to execute.</p>
<p>I m using database oracle. Please help.</p>
<p>I tried all queries mentioned above but none of them is working :(</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: harish</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-246490</link>
		<dc:creator><![CDATA[harish]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 07:51:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-246490</guid>
		<description><![CDATA[I tried all queries mentioned above but none of them is working :(]]></description>
		<content:encoded><![CDATA[<p>I tried all queries mentioned above but none of them is working :(</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: harish</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-246489</link>
		<dc:creator><![CDATA[harish]]></dc:creator>
		<pubDate>Wed, 01 Feb 2012 07:50:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-246489</guid>
		<description><![CDATA[HI all,

My requirements are:-

1) How many queries are hitting database
2) What are the queries
3) Which queries is taking long time to execute.

I m using database oracle. Please help.

Thanks in advance.]]></description>
		<content:encoded><![CDATA[<p>HI all,</p>
<p>My requirements are:-</p>
<p>1) How many queries are hitting database<br />
2) What are the queries<br />
3) Which queries is taking long time to execute.</p>
<p>I m using database oracle. Please help.</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vara Prasad</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-217045</link>
		<dc:creator><![CDATA[Vara Prasad]]></dc:creator>
		<pubDate>Tue, 13 Dec 2011 21:07:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-217045</guid>
		<description><![CDATA[Thanks a lot sreeKumar. If you find any script which combines both plz post it, would be much helpful.]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot sreeKumar. If you find any script which combines both plz post it, would be much helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ankit Shah</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-196120</link>
		<dc:creator><![CDATA[Ankit Shah]]></dc:creator>
		<pubDate>Tue, 15 Nov 2011 14:40:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-196120</guid>
		<description><![CDATA[Awesome I got it what iw as looking for 
Thank you so much for posting this query..]]></description>
		<content:encoded><![CDATA[<p>Awesome I got it what iw as looking for<br />
Thank you so much for posting this query..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sd</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-191923</link>
		<dc:creator><![CDATA[sd]]></dc:creator>
		<pubDate>Thu, 10 Nov 2011 00:10:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-191923</guid>
		<description><![CDATA[sumit dave, thanks again.]]></description>
		<content:encoded><![CDATA[<p>sumit dave, thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mannu</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-137032</link>
		<dc:creator><![CDATA[mannu]]></dc:creator>
		<pubDate>Fri, 27 May 2011 13:39:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-137032</guid>
		<description><![CDATA[thanks sir ,
please tell me abt function,procedure,trigger and joining]]></description>
		<content:encoded><![CDATA[<p>thanks sir ,<br />
please tell me abt function,procedure,trigger and joining</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-104618</link>
		<dc:creator><![CDATA[Andy]]></dc:creator>
		<pubDate>Fri, 10 Dec 2010 14:08:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-104618</guid>
		<description><![CDATA[You could just try studying using the Microsoft guides... thats what I did and it worked just fine.]]></description>
		<content:encoded><![CDATA[<p>You could just try studying using the Microsoft guides&#8230; thats what I did and it worked just fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gunjan Kalra</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-104571</link>
		<dc:creator><![CDATA[Gunjan Kalra]]></dc:creator>
		<pubDate>Fri, 10 Dec 2010 08:10:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-104571</guid>
		<description><![CDATA[Hi,

I want to do SQL server 2005 certification.
Can anyone please provide the DUMPS for the same.

Thanks in advance!

Gunjan Kalra]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I want to do SQL server 2005 certification.<br />
Can anyone please provide the DUMPS for the same.</p>
<p>Thanks in advance!</p>
<p>Gunjan Kalra</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sreekumar</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-101810</link>
		<dc:creator><![CDATA[Sreekumar]]></dc:creator>
		<pubDate>Wed, 24 Nov 2010 06:11:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-101810</guid>
		<description><![CDATA[hi guys , 
i want to find the queries ran and their time. , who ran it from which program. 

the first part is solved by 
-------------sql 1----------
use master 
SELECT 
t.TEXT QueryName,
s.execution_count AS ExecutionCount,
s.max_elapsed_time AS MaxElapsedTime,
s.creation_time AS LogCreatedOn
FROM sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t
ORDER BY s.max_elapsed_time DESC, ExecutionCount DESC

second part  gives database name hostname , program name , nt username and loginname 

-----------sql 2----------
SELECT DATEDIFF(MINUTE, a.last_batch, GETDATE()) RunningTime,
a.spid, a.blocked, a.waittime, db_name(a.dbid) As dbname,
a.last_batch, a.hostname, a.program_name,
a.nt_username, a.loginame, b.text as sqlstatement
FROM sys.sysprocesses A CROSS APPLY sys.dm_exec_sql_text(a.sql_handle) B
ORDER BY a.last_batch DESC

I need your help to combine query 1 and 2 as i am not familiar with cross apply . please help]]></description>
		<content:encoded><![CDATA[<p>hi guys ,<br />
i want to find the queries ran and their time. , who ran it from which program. </p>
<p>the first part is solved by<br />
&#8212;&#8212;&#8212;&#8212;-sql 1&#8212;&#8212;&#8212;-<br />
use master<br />
SELECT<br />
t.TEXT QueryName,<br />
s.execution_count AS ExecutionCount,<br />
s.max_elapsed_time AS MaxElapsedTime,<br />
s.creation_time AS LogCreatedOn<br />
FROM sys.dm_exec_query_stats s<br />
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t<br />
ORDER BY s.max_elapsed_time DESC, ExecutionCount DESC</p>
<p>second part  gives database name hostname , program name , nt username and loginname </p>
<p>&#8212;&#8212;&#8212;&#8211;sql 2&#8212;&#8212;&#8212;-<br />
SELECT DATEDIFF(MINUTE, a.last_batch, GETDATE()) RunningTime,<br />
a.spid, a.blocked, a.waittime, db_name(a.dbid) As dbname,<br />
a.last_batch, a.hostname, a.program_name,<br />
a.nt_username, a.loginame, b.text as sqlstatement<br />
FROM sys.sysprocesses A CROSS APPLY sys.dm_exec_sql_text(a.sql_handle) B<br />
ORDER BY a.last_batch DESC</p>
<p>I need your help to combine query 1 and 2 as i am not familiar with cross apply . please help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-99090</link>
		<dc:creator><![CDATA[Andy]]></dc:creator>
		<pubDate>Thu, 11 Nov 2010 14:31:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-99090</guid>
		<description><![CDATA[Hi Ian,

Just for information, I&#039;m running the DB on our server in 2000 compatability mode also, and found that the way to resolve the issue mentioned, was to run the query against the &quot;master&quot; database, rather than our databases.

Regards

Andy Bassitt]]></description>
		<content:encoded><![CDATA[<p>Hi Ian,</p>
<p>Just for information, I&#8217;m running the DB on our server in 2000 compatability mode also, and found that the way to resolve the issue mentioned, was to run the query against the &#8220;master&#8221; database, rather than our databases.</p>
<p>Regards</p>
<p>Andy Bassitt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://blog.sqlauthority.com/2009/01/02/sql-server-2008-2005-find-longest-running-query-tsql/#comment-99089</link>
		<dc:creator><![CDATA[Andy]]></dc:creator>
		<pubDate>Thu, 11 Nov 2010 14:29:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=1941#comment-99089</guid>
		<description><![CDATA[Sounds like the comment at the end is missing a - to make it :
SELECT DISTINCT TOP 10
t.TEXT QueryName,
s.execution_count AS ExecutionCount,
s.max_elapsed_time AS MaxElapsedTime,
ISNULL(s.total_elapsed_time / NULLIF(s.execution_count,0), 0) AS AvgElapsedTime,
s.creation_time AS LogCreatedOn,
ISNULL(s.execution_count / NULLIF(DATEDIFF(s, s.creation_time, GETDATE()),0), 0) AS FrequencyPerSec
FROM sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t
ORDER BY
s.max_elapsed_time DESC -- Maximum elapsed time, in microseconds

What seems to have happened is some autoformatting in windows, replacing -- with –]]></description>
		<content:encoded><![CDATA[<p>Sounds like the comment at the end is missing a &#8211; to make it :<br />
SELECT DISTINCT TOP 10<br />
t.TEXT QueryName,<br />
s.execution_count AS ExecutionCount,<br />
s.max_elapsed_time AS MaxElapsedTime,<br />
ISNULL(s.total_elapsed_time / NULLIF(s.execution_count,0), 0) AS AvgElapsedTime,<br />
s.creation_time AS LogCreatedOn,<br />
ISNULL(s.execution_count / NULLIF(DATEDIFF(s, s.creation_time, GETDATE()),0), 0) AS FrequencyPerSec<br />
FROM sys.dm_exec_query_stats s<br />
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t<br />
ORDER BY<br />
s.max_elapsed_time DESC &#8212; Maximum elapsed time, in microseconds</p>
<p>What seems to have happened is some autoformatting in windows, replacing &#8212; with –</p>
]]></content:encoded>
	</item>
</channel>
</rss>
