Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.
I was reading Grant’s Database Fundamental Series on Database Properties, and it got me thinking. I think this is a good set of knowledge to have, but building on the properties, can you check them programmatically?
You can, and here’s how.
There is a function, DatabasePropertyEX(), that provides you a way to check properties. You can use this with two parameters to check your database. These parameters are:
database name – The name of the database, where you can use dbname() for the current database.
Property name – These are a series of items to check a value for.
As an example, one of the items Grant mentions is the recovery model. I can check that with this code:
SELECT DATABASEPROPERTYEX(DB_NAME(), ‘Recovery’)
In the current database, I get this:
There are many properties I can check, and I can see a nice list here from SQL Prompt, or I can check the BOL page.
As nice as it can be to pop open SSMS and look at dialogs, learn to check things programmatically. Once you can do that, you can start to let the system check and alerts you to changes.