Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logging Processing time in SQL Code - @@timeticks? 1

Status
Not open for further replies.

HoustonGuy

Programmer
Jun 29, 2000
165
0
0
US
I would like to store processing time for each script I run.

The only global variable I see that I think might work is @@Timeticks - but I can't get a good calculation when converting it to seconds. I know it is machine dependent, but I would like to understand a basic conversion to seconds or minutes so I can store something readable/understandable for the end used.

How would you log processing time for a script?

Thank you in advance, my brothers and sisters!
 
You cannot convert @@TimeTicks to seconds because it returns the number of ticks per second and has nothing to do with duration.

When I time my code, I usually just do this...

Code:
Declare @Start DateTime
Set @Start = GetDate()

Exec ProcedureToTest

Select DateDiff(Millisecond, @Start, GetDate())

This may not be the most accurate method, but anything below a dozen milliseconds is hard to time.

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top