Determine time of last reboot

  • What's the best way of determining time of last server reboot from within a stored procedure?

    Thanks

  • select

    dateadd(ss, -1*ms_ticks/1000, getdate()) "Last server reboot time"

    from

    sys.dm_os_sys_info

  • Unfortunately we're on SQL Server 2000, not 2005.

     

  • TempDb is rebuilt from the ground up on a reboot... this does the trick...

     SELECT CrDate AS LastRebootDate

       FROM Master.dbo.SysDatabases

      WHERE Name = 'TempDB'

     

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thanks, but would this be the time of the last restart of SQL Server?  I'm looking for the Windows Server reboot.

  • Ack... my fault... I'm so data-centric that I sometimes forget that SQL Server has to live on a Windows server (except for MSDE, Development Edition, etc).

    Nope, I don't know how to do this one without using some undocumented feature (not usually a good idea) like xp_GetFileDetails or xp_RegRead or maybe a trip through xp_CmdShell (with the DIR cmd) to check a file date that is created during Windows Server bootup.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply