Pages

Thursday, September 25, 2008

code Execution Time

There are so many procedures in this world which are running very slow, to find out the execution time of the stored procedure you need to put simple statement like CURRENT_TIMESTAMP at the begining and ending of the stored procedure.

DECLARE @start DATETIME, @End DATETIME
SET @start = CURRENT_TIMESTAMP

DECLARE @i INT
SET @i = 0
WHILE @i < 24000
BEGIN
SET @i = @i + 1
END
SET @End = CURRENT_TIMESTAMP
SELECT DATEDIFF(MS, @start, @End)

No comments: