Thursday, February 9, 2012

SQL query to find the size of a database

SELECT DB_NAME(database_id) AS DatabaseName,
Name AS Logical_Name,
Physical_Name, (size*8)/1024 SizeMB
FROM sys.master_files
WHERE DB_NAME(database_id) = 'Sample'
GO

Here Sample is the name of the database.If you remove the WHERE condition you will find the result for all the databases.

No comments:

Post a Comment