How to measure stored procedure execution time?
You can use SET STATISTICS TIME ON, but it would return a timing for all single queries inside of your stored procedure. If you have a bunch of queries inside then it might be not very convenient. Here is a little code snippet alternative to STATISTICS TIME:
Declare @d datetime Set @d = CURRENT_TIMESTAMP -- Your stored procedure call goes here SELECT DATEDIFF(ms,@d,CURRENT_TIMESTAMP)
DBCC DROPCLEANBUFFERS to clear SQL Server cache for the cache-independent time measurement.
Posted on May 15, 2012 by Viktar Karpach