- Published on
Find Database size in SQL
- Authors
- Name
- Jeevan Wijerathna
- @iamjeevanvj
Find Tables by column names
I was in a situation where I need to quicly check the Database size. Usuall I use following quries to see the DB sizes
Query 1
with CteDbSizesas( select database_id, type, size * 8.0 / 1024 size from sys.master_files)select dbFileSizes.[name] AS DatabaseName, (select sum(size) from CteDbSizes where type = 1 and CteDbSizes.database_id = dbFileSizes.database_id) LogFileSizeMB, (select sum(size) from CteDbSizes where type = 0 and CteDbSizes.database_id = dbFileSizes.database_id) DataFileSizeMBfrom sys.databases dbFileSizes ORDER BY DataFileSizeMB desc
Query 2
exec sp_spaceused