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 2000 Forums
 Transact-SQL (2000)
 Finding when sp was last run?

Author  Topic 

Mathias
Posting Yak Master

119 Posts

Posted - 2004-05-03 : 02:21:06
I would like to do some cleaning. Is there a way to find out when a store procedure or function was last run?
Thanks Paul

nr
SQLTeam MVY

12543 Posts

Posted - 2004-05-03 : 02:32:15
Not unless you are logging it.
You can look at syscacheobjects to get some idea but I wouldn't rely on it.

If you suspect an SP isn't being used then add something to it to log to a table to check.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Mathias
Posting Yak Master

119 Posts

Posted - 2004-05-03 : 04:11:06
There is an option to compute statistics, this is not related to this? I had the impression that the more a sp is used, the more SQL will try to move it to the RAM and that SQL uses the stats for this.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-05-03 : 04:26:08
Statists are related to the distribution of columns or indexes. When a query is run if the statistics are marked as out of date the will (if configured) be recomputed. They are disk based and not related to how often the SP is run.
When an SP or any query is run a query plan is generated and held in the procedure cache (see syscacheobjects). When it is run again the query plan will be reused based on the sql input (a cahce hit). The plan will remain in memory until it is dumped so that the memory can be used for something else or until it is aged (decided to be no longer valid - maybe due to statistics generation).

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -