Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Find Stored Procedure Exection Time

Author  Topic 

Prabu.Ramaiah
Starting Member

15 Posts

Posted - 2009-07-07 : 00:50:30
I have created one stored proc. How to find the execution time in case the time in Sec or M.Sec

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-07 : 01:53:56
declare @date datetime
set @date=getdate()
exec procedure
select datediff(second,@date,getdate())

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-07-07 : 03:41:47
Hi

sys.dm_exec_query_stats - Returns performance statistics for cached query plans. This contains one row per query plan so if a stored procedure or batch contains two SELECT statements you may get two rows here....




-------------------------
Your time is a valuable resource.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-07 : 05:06:43
quote:
Originally posted by rajdaksha

Hi

sys.dm_exec_query_stats - Returns performance statistics for cached query plans. This contains one row per query plan so if a stored procedure or batch contains two SELECT statements you may get two rows here....




-------------------------
Your time is a valuable resource.


Provided OP uses SQL Server 2005 (or more) version

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-08 : 12:02:10
quote:
Originally posted by Prabu.Ramaiah

I have created one stored proc. How to find the execution time in case the time in Sec or M.Sec


you can also get this by running profiler and looking for sp started and sp completed counter values
Go to Top of Page
   

- Advertisement -