Wednesday 2 March 2011

Find out how big your databases are in SQL Server

Get a list of all database sizes in KB for the whole SQL server.
Create Table #temp (
    table_name varchar(200) ,
    database_size int,
    remarks varchar(50)
  )

  SET NOCOUNT ON
  insert #temp exec sp_databases

  select 
    table_name, 
    cast(database_size / 1024 as nvarchar)+ ' KB' 
  from 
    #temp
  order by 
    database_size desc

  drop table #temp
An example of what gets shown can bee seen below:-