Today i am posting the methods to find the size of database through the sql statement.
Method 1: Using sp_helpdb
The below statement gives the information about all the databases:
EXEC sp_helpdb
whereas the below gives the information about a specified database (in this case about master database):
EXEC sp_helpdb N'master'
Method 2: Using sys.master_files
It is a system view which contains a row per file of a database as stored in the master database:
SELECT DB_NAME(database_id), SUM(size)*8/1024 as size_in_MB FROM sys.master_files GROUP BY database_id