How to Find the SQL Server Instance Startup Time

  • Comments posted to this topic are about the item How to Find the SQL Server Instance Startup Time

  • Nicely written, Nisarg .  And the annotations in the screen shots are helpful and also nicely done.

    --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, very useful info! Just a small remark about finding the start time in the ERRORLOG. The log may have been re-initialized so the current log file might not include the message 'ready for client connections'. Depending on how long it's been running and the number of log rollovers you may not be able to find that message in any of the ERRORLOG files.

    Maybe it's better to search for a message like 'This instance of SQL Server has been using a process ID of <pid> since <sql start time>' (not sure if this is applicable to all version though)

     

     

  • Also, Below is a great T-SQL script to find startup time for SQL server, SQL Server agent and windows server.

    -- ============================================================= --

    -- Get OS, SQL Server, SQL Agent Restart times

    select

    @@SERVERNAME AS Instance_Name,

    [OS Start Time] = convert(varchar(23),b.OS_Start,121),

    [SQL Server Start Time] = convert(varchar(23),a.SQL_Start,121),

    [SQL Agent Start Time] = convert(varchar(23),a.Agent_Start,121),

    [OS Uptime] =

    convert(varchar(15),

    right(10000000+datediff(dd,0,getdate()-b.OS_Start),4)+' '+

    convert(varchar(20),getdate()-b.OS_Start,108)),

    [SQL Uptime] =

    convert(varchar(15),

    right(10000000+datediff(dd,0,getdate()-a.SQL_Start),4)+' '+

    convert(varchar(20),getdate()-a.SQL_Start,108)) ,

    [Agent Uptime] =

    convert(varchar(15),

    right(10000000+datediff(dd,0,getdate()-a.Agent_Start),4)+' '+

    convert(varchar(20),getdate()-a.Agent_Start,108))

    from

    (

    Select

    SQL_Start = min(aa.login_time),

    Agent_Start =

    nullif(min(case when aa.program_name like 'SQLAgent %' then aa.login_time else '99990101' end),

    convert(datetime,'99990101'))

    from

    master.dbo.sysprocesses aa

    where

    aa.login_time > '20000101'

    ) a

    cross join

    (

    select

    OS_Start = dateadd(ss,bb.[ms_ticks]/-1000,getdate())

    from

    sys.[dm_os_sys_info] bb

    ) b

    -- ------------------------------------------------------------- --

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

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