Find the execution time of a stored procedure

The best way is to use SQL profiler. Just choose the required events.Else if you dont have the permission to access SQL Profiler or want to determine that programatically, then try:

 

DECLARE @StartDate datetime, @EndDate datetime

SET @StartDate = getdate()

 

/*

--Exec your stored procedure code here--

*/

 

SET @EndDate = getdate()

 

SELECT datediff(ms,@StartDate, @EndDate) AS 'Milliseconds'

Ebook Download
View all
Learn
View all