How can I determine when the state of a specific database switched to online?
Background: I want to determine how long the database is in use to find out how reliable
sys.dm_db_index_usage_stats currently is.
As @SQLLearner specificed in his answer, the easiest way without auditing in place or an XE session running would be to just look in the SQL Server Log. The below code will get the most recent startup of a particular database (using
As per @usr's comment an Connect link, in SQL Server 2012 Unicode parameters are required.
You can look into sys.dm_os_sys_info DMV and sqlserver_start_time to determine when SQL Server service was started. This was also start point for sys.dm_db_index_usage_stats DMV.
If you want to find out when specific database was bought onine, you need to look into SQL Server ErrorLog for something like "Starting up Database"