Total Pageviews

Search This Blog

Saturday, May 2, 2009

sys.database_files to query database metadata

Looking to query database metadata info like files, physical path, size, state etc. then you should try querying sys.database_files table.
It will retreive the information relating to the current database from where you are querying (Assuming here that you are using Query Editor)
select * from sys.database_files
Here, size is returned in 8 KB page
To convert the size into MB's, one can use this query
select (size*1.0/128),* from sys.database_files
More info regarding this table and fields would be found at the following msdn link

No comments: