Wednesday, March 21, 2012

Measuring serve uptime

I am trying to create a report which gives total time
between SQL server start up and shut down. I have created
a stored procedure which runs at server startup and
inserts date and time into a table.Is there some way I can
find the server shutdown time as well.
Thanks,
AnoopCheck the SQL log files.
"Anoop Agarwal" <agarwala@.halcrow.com> wrote in message
news:0a9701c37cfb$8d29d3b0$a301280a@.phx.gbl...
> I am trying to create a report which gives total time
> between SQL server start up and shut down. I have created
> a stored procedure which runs at server startup and
> inserts date and time into a table.Is there some way I can
> find the server shutdown time as well.
> Thanks,
> Anoop|||You can parse the SQL Server log files (not to be confused with the
transaction log files). They are plain text files called ERRORLOG you can
find in the LOG directory of your SQL Server installation. The first line
will give you the server start up time and the last line the server shut
down time.
--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.
"Anoop Agarwal" <agarwala@.halcrow.com> wrote in message
news:0a9701c37cfb$8d29d3b0$a301280a@.phx.gbl...
> I am trying to create a report which gives total time
> between SQL server start up and shut down. I have created
> a stored procedure which runs at server startup and
> inserts date and time into a table.Is there some way I can
> find the server shutdown time as well.
> Thanks,
> Anoop|||The more I think about it the ErrorLog can't be relied upon. Someone could
have issued sp_cycle_errorlog and manually started a new errorlog.
There is an NT Event written to the EventLog when SQL Stops
17147 :
SQL Server terminating because of system shutdown.
If you could read this informatrion it would be more reliable. I know of a
proc called sp_eventlog but don't know how it works
HTH
Ryan Waight, MCDBA, MCSE
"Ryan Waight" <Ryan_Waight@.nospam.hotmail.com> wrote in message
news:uPLlelQfDHA.944@.TK2MSFTNGP11.phx.gbl...
> TempDB is created each time SQL starts by default. The following code will
> give you the time SQL Started :- select crdate from sysdatabases where
name
> = 'TempDB'
> To establish when SQL was stopped you could try sp_readerrorlog 1 - this
> will show you previous error log, the max time in this file is SQL
shutting
> down
> --
> HTH
> Ryan Waight, MCDBA, MCSE
> "Anoop Agarwal" <agarwala@.halcrow.com> wrote in message
> news:0a9701c37cfb$8d29d3b0$a301280a@.phx.gbl...
> > I am trying to create a report which gives total time
> > between SQL server start up and shut down. I have created
> > a stored procedure which runs at server startup and
> > inserts date and time into a table.Is there some way I can
> > find the server shutdown time as well.
> >
> > Thanks,
> >
> > Anoop
>|||Check the SQLagent.out file?
>--Original Message--
>I am trying to create a report which gives total time
>between SQL server start up and shut down. I have
created
>a stored procedure which runs at server startup and
>inserts date and time into a table.Is there some way I
can
>find the server shutdown time as well.
>Thanks,
>Anoop
>.
>|||Check the SQLagent.out file?
>--Original Message--
>I am trying to create a report which gives total time
>between SQL server start up and shut down. I have
created
>a stored procedure which runs at server startup and
>inserts date and time into a table.Is there some way I
can
>find the server shutdown time as well.
>Thanks,
>Anoop
>.
>sql

No comments:

Post a Comment