I have to include one report in my application showing offline/online activity of few databases on SQL Server 2008. Could you please suggest how can I collect teh same information from sql server?
+2
A:
SELECT DATABASEPROPERTYEX('YOURDATABASE', 'Status') DatabaseStatus_DATABASEPROPERTYEX GO
SELECT state_desc DatabaseStatus_sysDatabase FROM sys.databases WHERE name = 'YOURDATABASE' GO
This will tell you the status of the database.
Ardman
2010-03-15 13:36:36
Using these queries I can find out if the database is offline/online at present. However, I am looking for a way to know the time when the database went online /offline last time.
2010-03-16 09:00:25
+2
A:
In order to find out when your database was taken OFFLINE, you can use the SQL that I posted before, or the easiest way is to check the Event Viewer and it will tell you when the Database was taken OFFLINE. I have just tested this on my local machine and SQL Server writes out an Information message to the Application log.
Ardman
2010-03-16 09:46:18