Friday, March 23, 2012

how many times the store procedure was execute when the server start

I was wondering if there was any way to know how many times the store procedure was execute when the server start.

When you say on server start do you mean when you boot the server / start the sql serivce? Are you refering to start-up procs (sp_procoption)?|||

Not sure what you are looking for or what version of SQL Server you are using but one option with cached query plans in 2005, you can get execution counts from sys.dm_exec_query_stats.

You can view the execution counts with something along the lines of:

SELECT *
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
ORDER BY execution_count desc

For a specific stored proc, you can use something like:

SELECT object_name(objectid), execution_count
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(sql_handle)
WHERE objectid = object_id('YourStoredProcedureName')

-Sue

No comments:

Post a Comment