• I tried but it is giving below error as the sp_spaceused output is in two rows.

    Msg 213, Level 16, State 7, Procedure sp_spaceused, Line 113

    Column name or number of supplied values does not match table definition.

    Below are the queries I am executing.

    create table #temp1

    (

    dbname varchar(20),dbsize varchar(20),unallocatedspace varchar(20),reserved varchar(20),data varchar(20),index_size varchar(20),unused varchar(20))

    insert into #temp1 (dbname,dbsize,unallocatedspace,reserved,data,index_size,unused)

    exec sp_msforeachdb

    @command1='use ?; exec sp_spaceused'