There are several ways to get database sizes in a server. Following three system tables has the information to get database sizes.
You also can use following system stored procedure.
However the easiest way is to use SP_HELPDB system stored procedure. Below script used that SP to get the database sizes in a server.
create table #spdbdesc
dbsize nvarchar(13) null,
owner sysname null,
dbid smallint primary key,
dbdesc nvarchar(600) null,
INSERT INTO #spdbdesc