Thursday, July 14, 2011

Calculate Execution Time of the Query

Calculate Execution Time of the Query: "Method 1:


DECLARE @StartTime datetime
,@EndTime datetime

SELECT @StartTime=GETDATE()

SELECT * FROM tblmastertable ORDER BY Insertion_time DESC

SELECT @EndTime=GETDATE()

SELECT DATEDIFF(ms,@StartTime,@EndTime) AS [Duration in millisecs]



Method 2:

SET STATISTICS TIME ON

SELECT * FROM tblmastertable ORDER BY Insertion_time DESC

SET STATISTICS TIME OFF
"

No comments:

Post a Comment