March 3, 2009 at 2:52 pm
We have SQL Server 2000. I would like to add a timestamp before and after a job step. I was thinking of something like the following (I would need to add the seconds and miliseconds to the date statements):
In the Job Step Command Box:
SELECT 'StartTime is: '+ CONVERT(char(30), CURRENT_TIMESTAMP)
GO
DBCC DBREINDEX (TableA,'', 70)
GO
DBCC DBREINDEX (TableB,'', 70)
GO
DBCC DBREINDEX (TableC,'', 70)
GO
SELECT 'EndTime is: '+ CONVERT(char(30), CURRENT_TIMESTAMP)
GO
SELECT GETDATE() AS StartTime
GO
DBCC DBREINDEX (TableA,'', 70)
GO
DBCC DBREINDEX (TableB,'', 70)
GO
DBCC DBREINDEX (TableC,'', 70)
GO
SELECT GETDATE() AS EndTime
GO
Thanks, Kevin
March 3, 2009 at 9:33 pm
Both look good. I feel GetDate() would be more apt.
Pradeep Adiga
Blog: sqldbadiaries.com
Twitter: @pradeepadiga
March 3, 2009 at 10:04 pm
If you're going to do it that way then getdate() is the best way to go.
However, I normally query the msdb..sysjobhistory table to get the starttime (warning, run_date and run_time are stored as integers, in the format yyyymmdd and hhmmss respectively) and the duration (stored in seconds).
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply