Monday, October 21, 2013

How to determine list of all the databases and size of the database ?

 

Dear All,

Sometimes you require list of all the database and size.

To achieve this we need to write  following script

 

   1:  
   2: SELECT sd.name,Convert(Decimal(10,0),(mf.size /1024)) As size
   3: FROM 
   4: sysdatabases sd
   5: INNER JOIN sys.master_files mf ON mf.database_id = 
   6: sd.dbid
   7:  
   8: AND mf.type = 0 
   9: WHERE sd.Name Not IN ('MASTER','tempdb','Model','MSDB')

 



Hope it will resolve your query. Enjoy :)


Rajat Jaiswal