Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On SQL Server 2008, how to find out when was any database offline/online?

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 the same information from sql server?

like image 280
user293925 Avatar asked Oct 27 '25 05:10

user293925


2 Answers

You can also use below query to check database status.

SELECT Name, state_desc FROM sys.databases
like image 191
Srinivasa Ganamur Avatar answered Oct 29 '25 19:10

Srinivasa Ganamur


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.

like image 33
Neil Knight Avatar answered Oct 29 '25 20:10

Neil Knight