Swim in SQL server

Posts tagged ‘Sored Procedure’

How to get the last execution Time of Stored Procedure

–With Text:
SELECT
                 qs.sql_handle,qs.statement_start_offset,qs.statement_end_offset,
                 qs.creation_time,qs.last_execution_time,qp.dbid,qp.objectid
FROM      sys.dm_exec_query_stats AS qs
                 CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) AS st
                 CROSS APPLY sys.dm_exec_text_query_plan(qs.plan_handle, DEFAULT, DEFAULT) AS qp
WHERE  st.text like '%S_GET_SerialNos%'
 
 
–Tip2:
SELECT      db_name(database_id) DatabaseName, object_name(object_id) ObjectName, *
FROM          sys.dm_exec_procedure_stats
WHERE      database_id = DB_ID()
ORDER BY database_id