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.
| Author |
Topic |
|
nmarks
Yak Posting Veteran
53 Posts |
Posted - 2007-10-09 : 04:28:37
|
| Hi,I've written a T-SQL script and need to record how long it takes to execute from start to end. It only takes between 5 and 10 seconds but I need to know accurately, ideally including milliseconds.I have written a short script to show the times at the start and end of execution but these are only shown to the minute. I need greater accuracy. Can anyone help?Here the code I've written:Use appropriate_databaseDECLARE @t1 DATETIME;DECLARE @t2 DATETIME;DECLARE @t3 DATETIME;SET @t1 = getdate()print @t1execute sp_run_jobSET @t2 = getdate()print @t2 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-10-09 : 04:34:58
|
DECLARE @t1 DATETIMEUse appropriate_databaseSET @t1 = getdate()execute sp_run_jobprint datediff(ms, @t1, getdate()) as timetakenmilliseconds E 12°55'05.25"N 56°04'39.16" |
 |
|
|
nmarks
Yak Posting Veteran
53 Posts |
Posted - 2007-10-09 : 04:38:28
|
| Great, much appreciated |
 |
|
|
|
|
|