Solved

Which SQL Server Stored Procedures have been executed

Posted on 2007-04-03
9
189 Views
Last Modified: 2010-03-19
In SQL Server version 2000 or 2005,  is there a way I can determine which stored procedures in a database  have been executed over the past 6 months, or alternatively, is there something I can do (without modifying the stored procedures themselves) to determine which stored procedures have been executed over the next month  ?  
0
Comment
Question by:vd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18848478
unless you put in place a change in the procedure OR put in place a trace, there is no way to know.
0
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 18849398
<<In SQL Server version 2000 or 2005,  is there a way I can determine which stored procedures in a database  have been executed over the past 6 months, or alternatively, is there something I can do (without modifying the stored procedures themselves) to determine which stored procedures have been executed over the next month  ?>>
No.
0
 
LVL 19

Expert Comment

by:Rimvis
ID: 18849902
Yes you can
         
Identifying Unused Objects in a Database
http://www.sqlservercentral.com/columnists/lPeysakhovich/2582.asp
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 18849968
<<Yes you can>>
What does identifying *unused* objects with identifying *all* procedures used over a period of time?  Are you saying that *all* procedures are *unused*?

0
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 18849975
Sorry typo, I of course meant
What does identifying *unused* objects has to do with identifying *all* procedures used over a period of time?
0
 
LVL 19

Expert Comment

by:Rimvis
ID: 18850027
Did you read the article?
No, there is no "SELECT * FROM sysunusedproc"
It describes a way of detecting unused SPs based on cached execution plan.
0
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 18850780
<<<Did you read the article?>>
Yes and I did not find any answer to the question I have tried to raise.  

<<It describes a way of detecting unused SPs based on cached execution plan. >>
No doubt about that but it seems to me that the question is *is there a way I can determine which stored procedures in a database  have been executed over the past 6 months* .  How does that relate to unused SP's.  Are you suggesting that an unused proc is *de facto* the opposite of historically used sp's?  What about sp's that have been deleted?

Trying to understand what you're trying to get at...

Regards...
0
 
LVL 19

Accepted Solution

by:
Rimvis earned 125 total points
ID: 18851059
No, you can't immediately detect, what SPs weren't executed over last 6 moths, one month or whatever.
At first,  cached plans (from SYSCACHEOBJECTS) must be cleared. Now, if SP was executed, there is a record in SYSCACHEOBJECTS. After a month, you could check SYSCACHEOBJECTS. If there's no record for some SP, it wasn't executed. It looks simple to me, unless I'm missing something.

>>What about sp's that have been deleted
Well, then you can't detect, if it was ever executed or not. But I don't this it is a big problem.

0
 
LVL 23

Expert Comment

by:Racim BOUDJAKDJI
ID: 18851220
<<No, you can't immediately detect, what SPs weren't executed over last 6 moths, one month or whateve>>
But the point is to detect that *were* executed in the past *6 monthes* *not* just the sp's that were executed in the past month and the one that were recorded.  What gives you the guarantee for instance that the cache was not cleared?  what if some sp's became obsolete...
 
<<No, you can't immediately detect, what SPs weren't executed over last 6 moths, one month or whatever.
At first,  cached plans (from SYSCACHEOBJECTS) must be cleared. Now, if SP was executed, there is a record in SYSCACHEOBJECTS. After a month, you could check SYSCACHEOBJECTS. If there's no record for some SP, it wasn't executed. It looks simple to me, unless I'm missing something.>>
Let me get this straight.  You are basically saying that the syscacheobjects system tells what sp were ran in the last month from the time the cash was cleared.  Right?  

But the question states that the user wants to find out what procedures were executed in the past *6 monthes* which makes a huge difference between what you can achieve through the suggested method.  

<<It looks simple to me, unless I'm missing something.>>
I think it looks simple only to you ;)

I believe the method suggested may help get some information but I am not convinced it answers the question.  So for the moment I'd stick to what angelII and I said. (meaning there is no way to do it unless done with explicit logging)

Regards...
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question