Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Return only the ObjectName from DMVs...

Author  Topic 

NguyenL71
Posting Yak Master

228 Posts

Posted - 2014-02-12 : 14:34:32


Hi,

When I ran the DMV below, I got details info but how can I can the top 20 SP name from the queries below.
Please see the desired results below.

Thank you so much in advance.


-- Listing 4.6 The queries that use the most I/O
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

SELECT TOP 20
--[Total IO] = (qs.total_logical_reads + qs.total_logical_writes)
--, [Average IO] = (qs.total_logical_reads + qs.total_logical_writes) /
-- qs.execution_count
--, qs.execution_count
SUBSTRING (qt.text,(qs.statement_start_offset/2) + 1,
((CASE WHEN qs.statement_end_offset = -1
THEN LEN(CONVERT(NVARCHAR(MAX), qt.text)) * 2
ELSE qs.statement_end_offset
END - qs.statement_start_offset)/2) + 1) AS [Individual Query]
, qt.text AS [Parent Query]
--, DB_NAME(qt.dbid) AS DatabaseName
--, qp.query_plan
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) as qt
CROSS APPLY sys.dm_exec_query_plan(qs.plan_handle) qp
ORDER BY [Total IO] DESC


-- Desired Results:
-------------
CREATE PROCEDURE [dbo].[usp_HOS_InsertDailySummary]
CREATE PROCEDURE [dbo].[asp_Application_GetEventTrackingDataActivity]

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-02-12 : 17:36:45
Looks like you got your answer already: http://social.technet.microsoft.com/Forums/en-US/8f56c0aa-cf5b-4fb2-8eb8-fd1e1e259028/return-only-the-objectname-from-dmvs?forum=transactsql

I am intrigued by your stored procedure names. They look similar to ones that I support. Does HOS stand for Hours of Service?

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -