February 10, 2006 at 7:08 am
What is the best method to time the execution of a stored procedure? I was thinking about printing or selecting the Current_TimeStamp at the beginning of the SP and at the end of the SP. We have SQL Server 2000 (SP3).
Thanks in advance for you assistance, Kevin
February 10, 2006 at 7:35 am
Write at the beginning and at the end of store proc: print getdate().
February 10, 2006 at 11:48 pm
If you just want duration and not actual CPU seconds used, then something like this works...
--===== Declare a couple of variables to measure duration
DECLARE @StartTime DATETIME
DECLARE @EndTime DATETIME
--===== Start the duration "timer"
SET @StartTime = GETDATE()
--===== Run the code being tested
yada-yada-yada
--===== Stop the duration "timer
SET @EndTime = GETDATE()
--===== Finally, display the total duration of the test
-- code in decimal seconds
SELECT CONVERT(VARCHAR(20),@EndTime-@StartTime,114)
... will display the duration in the hh:mm:ss:mil format and is good up to 24 hours.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply