January 2, 2008 at 9:57 am
I need a way to find out when a database was brought online last using ASP.NET. I don't need the create date. It's for an administration module that I'm writing for a web application. Basically, I just want to be able to see how long a particular database has been online with no service interruptions.
I know that I can see that info in the Server Log (filter by "starting up database 'database'") but I can't find a way to get the data from the server log into a table or view that I can query ans subsequently pull into ASP.NET
Any ideas?
Thanks!
January 3, 2008 at 7:00 am
You need to use the function Exec master..xp_readerrorlog and store the data into a table where you can filter it.
Declare @ErrorLog Table (LogID int identity(1, 1) not null primary key,
LogDate datetime null,
ProcessInfo nvarchar(100) null,
LogText nvarchar(4000) null)
Insert Into @ErrorLog (LogDate, ProcessInfo, LogText)
Exec master..xp_readerrorlog
Select *
From @ErrorLog
WHERE logtext LIKE '%starting up database%'
January 3, 2008 at 7:15 am
Awesome, thanks!
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply