Wednesday, March 31, 2010

Calculate the execution time of query

DECLARE @start datetime
SELECT @start = getdate()
BEGIN TRANSACTION
-- Stuff to test comes here.
--Select * from tbltest
Declare @int int
Set @int = 0
Print @start
While(@int < 200000)
Begin
Print @int;
Set @int = @int +1
End
--PRINT 'It took ' + ltrim(str(datediff(ss, @start, getdate()))) + ' sec.'
Select Ltrim(STR(DATEDIFF(SS,@Start,Getdate())))+ ' Sec'
ROLLBACK TRANSACTION

No comments:

Post a Comment