Browse by Tags

TSQL to get current executing statements - SQL Server 2005
12 February 08 01:27 PM | SQL Master | 4 Comments   
Using SP_WHO or SP_WHO2 is a common way to get list of executing processes currently on the server, within SQL Server 2005 you could take advantage of DMV that lists currently-executing statements. select r.session_id ,status ,substring(qt.text,r.statement_start_offset/2, Read More...
Show text from sql_handle
04 October 07 03:50 AM | SQL Master | 2 Comments   
Based upon the query or stored procedure execution the plan will be stored in the cache, but it may not be in readable format as it is stored in Hexadecimal when you simply query SYSPROCESSES table. So in order to extract the query plan that is in cache, Read More...
TSQL to list the most used query plans
28 September 07 01:12 AM | SQL Master | 2 Comments   
select TOP 100 objtype, p.size_in_bytes, LEFT([sql].[text], 100) as [text] from sys.dm_exec_cached_plans p outer apply sys.dm_exec_sql_text (p.plan_handle) sql ORDER BY usecounts DESC Read More...