| Author |
Topic |
|
amitsyadav
Starting Member
15 Posts |
Posted - 2006-09-12 : 09:54:06
|
| Hi All, I want to capture the total time taken by SQL Server for execution of a Stored Procedure. Please suggest. Thanks in advance. Amit |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-09-12 : 10:05:32
|
| run your procedure through query analyser and see the time taken for execution at the button of the screen.Chirag |
 |
|
|
sanjnep
Posting Yak Master
191 Posts |
Posted - 2006-09-12 : 10:09:13
|
| declare @st_dt datetimedeclare @end_dt datetimeselect @st_dt = getdate()exec your_procedureselect @end_dt = getdate()--use @end_dt - @st_dt with datediff function ThanksSanjeev Shrestha12/17/1971 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-12 : 10:10:16
|
| set statistics TIME onselect * from f_table_number_range(1, 100000)set statistics TIME offPeter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-12 : 10:10:56
|
quote: Originally posted by chiragkhabaria run your procedure through query analyser and see the time taken for execution at the button of the screen.
Not 1001, 1002, 1003, 1004...? Peter LarssonHelsingborg, Sweden |
 |
|
|
amitsyadav
Starting Member
15 Posts |
Posted - 2006-09-12 : 10:25:50
|
quote: Originally posted by Peso set statistics TIME onselect * from f_table_number_range(1, 100000)set statistics TIME offPeter LarssonHelsingborg, Sweden
Peter,Thanks but i am not getting you clearly. Actually I want to capture the total time taken in the execution of a SP by the SQL server in my report. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-12 : 10:31:42
|
| Now we finally are getting some real information about how the information is going to be used!Use the suggestion by sanjnep.Peter LarssonHelsingborg, Sweden |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
amitsyadav
Starting Member
15 Posts |
Posted - 2006-09-12 : 10:41:44
|
thanks Sanjeev.quote: Originally posted by sanjnep declare @st_dt datetimedeclare @end_dt datetimeselect @st_dt = getdate()exec your_procedureselect @end_dt = getdate()--use @end_dt - @st_dt with datediff function ThanksSanjeev Shrestha12/17/1971
|
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-09-12 : 12:14:05
|
| orCREATE PROCEDURE MySProc ... parameters ... @ElapsedTime int = NULL OUTPUTASDECLARE @StartTime datetimeSELECT @StartTime = GetDate()... do stuff ...SELECT @ElapsedTime = DATEDIFF(millisecond, @StartTime, GetDate())RETURNGOor you could SELECT the elapsed time to it is part of the resultset, rather than an OUTPUT parameter from your SProc, if that suits your reporting environment better.Kristen |
 |
|
|
amitsyadav
Starting Member
15 Posts |
Posted - 2006-09-13 : 03:50:02
|
| Thanks everyone, I just want to check if this could be done in another way.Thanks once again.Amit |
 |
|
|
|