I am trying to figure out if there\'s a way to identify a \"version\" of a SP that gets called the most. I have an SP that gets called with a bunch of different parameters. I kn
It sounds like you only need to be able to capture this information for a short period of time. The sproc may be called a large number of times during that period, but it's a finite period.
If that is the case, perhaps you could log the sproc calls somewhere? If you have control over the sproc code, you could perform the logging there. One approach would be to create a special table for this purpose, add an INSERT to that table at the beginning or end of the existing sproc, and wait for some records to accumulate in the table.
Depending on the specifics, you could create a column in the custom logging table for each sproc parameter.
Then you'd have ample information about the usage of the sproc, for the period of time you perform the logging.
Given the data accumulated in the table, you could query to find the most frequent parameter values, which users or applications or web pages, etc. are entailed, the datetimes for the beginning and ending of the sproc call, and whatever else you log.
This would not involve any changes to the application code, and it could be completely eliminated after you have completed your troubleshooting. So, aside from the inevitable performance hit of all that logging, the price of this approach is not high.
Edit: This approach would be an alternative for users who lack the special permissions required to run DMV queries on tables such as sys.dm_exec_query_stats. In many shops, getting such permissions -- particularly on production databases -- is not feasible for developers.