How to get size of Database Data file and Log file size in sql server

Please run this query and you will get log and data file size in sql server

 SELECT database_id,CONVERT(VARCHAR(25), DB.name) AS dbName,



(SELECT SUM((size*8)/1024) FROM sys.master_files



WHERE DB_NAME(database_id) = db.name AND type_desc = 'rows') DATA_MB,



(SELECT SUM((size*8)/1024) FROM sys.master_files



WHERE DB_NAME(database_id) = db.name AND type_desc = 'log') AS [Log MB] FROM sys.databases DB



WHERE name in (select name from sys.databases)