database uptime, an easy check?

  • Is there an easy way to check how long a specific database has been online?

    I know there are various methods for the sql server instance in general (tempdb create time), but what about individual databases?

    If one database goes offline, checking instance start time doesn't really do the job.

    I was previously obtaining this information via:

    Create Table #TmpLog(LogDate datetime, ProcessInfo varchar(255), TextStr varchar(7000))

    INSERT #TmpLog exec master.dbo.sp_readerrorlog

    create table #ParcedErrorLog (eventTime datetime, TextStr varchar(7000))

    INSERT INTO #ParcedErrorLog

    SELECT Max(LogDate)

    ,SUBSTRING(LTRIM(RTRIM(TextStr)),23,LEN(TextStr)-24)

    From #TmpLog

    where TextStr like '%Starting up database%'

    group by SUBSTRING(LTRIM(RTRIM(TextStr)),23,LEN(TextStr)-24)

    However, this is slow and often fails in the case of large error logs. Is there another way? Wouldn't this seem like relevant info?

Viewing post 1 (of 1 total)

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