SQLTeam.com | Weblogs | Forums

Is there a way to find out the status of a SQL Server database?

sql2008

#1

I want to write some routines to check whether a database is online as well as to determine some other information about the status of a database. What options are there to get status of a SQL server database without using the GUI?


#2
SELECT *
FROM sys.databases

may have what you need


#3

I would suggest you to have a Admin DB which keep the last status of the DB (this is what I have done myself) as you might have some DB that is offline on purpose, and if you only check the DB is online, you might keep getting false alert. Instead, I check the status change compare to last check (whatever the interval is), and if that status change, then I will get an alert.

Hope this helps


#4

Thanks for your helpful suggestions