SQL Server File Size
There are serveral ways to find out database size. Apart from using the SSMS GUI, you can using following scripts options.
--this return size info for all databases --the size is in kilobytes exec sp_databases --this return size info for all databases SELECT DBName = DB_NAME(database_id) ,FileName = name ,physical_name ,type_desc ,Allocated_Space_GB = CONVERT(DECIMAL(18,2),size * 8.0/1024/1024) --,max_size --,growth --,is_percent_growth FROM sys.master_files WHERE database_id > 6 AND type IN (0,1) --this return size info for current database with free space info SELECT DBName = DB_NAME() ,FileName = name ,physical_name ,type_desc ,Allocated_Space_GB = CONVERT(DECIMAL(18,2),size * 8.
Posted by John Liu Sunday, March 19, 2023