Any system stored proc/dbcc commands to find out how long the sqlserver was running ?

  • hi,

      which dbcc command/sp_ /xp_ used to find out how long sqlserver is running(ie., when its started or restarted)

     

    Thanks in advance

     

  • This will give you the uptime in days:

    SELECT

    CAST((CAST(DATEDIFF(ss, login_time, GETDATE()) AS DECIMAL(9,2)) / 86400) AS DECIMAL(6,2))

    FROM

    master..sysprocesses WHERE spid = 1

    or, since tempdb is always recreated when SQL Server startes you can do:

    SELECT

     DATEDIFF(hh,crdate,GETDATE()) AS UpTimeInStunden

    FROM

     master.dbo.SYSDATABASES

    WHERE

     Name = 'TempDB'

    There is also a tool named uptime.exe, which is on the resource kit.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Or look at the sql error log if it hasn't been recycled yet since the last restart.

  • Or, in Ent. Manager goto Taskpad of TEMPDB, look at create date. The TEMPDB gets recreated when SQL Server is stopped and started.

Viewing 4 posts - 1 through 3 (of 3 total)

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