We are using SQL Server 2005 for production and the database compatability level is kept for 80 not 90. I have a qery for
finding the long running queries which supports on SQL 2005 not 2000 database. Its throwing error when i run the query
to identify the long running queries.
select top 50
qs.total_worker_time / execution_count as avg_worker_time,
when -1 then datalength(st.text)
end - qs.statement_start_offset)/2) + 1) as statement_text,
sys.dm_exec_query_stats as qs
cross apply sys.dm_exec_sql_text(qs.sql_handle) as st
Server: Msg 170, Level 15, State 1, Line 11
Line 11: Incorrect syntax near 'apply'.
Can anyone please have a look into this to work fine for 2000 compatibility databases.
Or else anyone please provide me the query for identifying the long running queries.