Using sp_spaceused and database_size and Keep Info

  • I've been using sp_spaceused to manually view database sizes.

    Q. How can use database_size in Select statement and Insert the results into another table?

     

     

  • This works in 2000, no idea for 2k5.

     

    IF OBJECT_ID('tempdb..#su') > 0

     DROP TABLE #su

    GO

    CREATE TABLE #SU (Name varchar(128), Rows varchar(25), Reserved varchar(25), data varchar(25), index_size varchar(25), unused varchar(25))

    INSERT INTO #SU (Name, rows, Reserved, data, index_size, unused)

    EXEC SP_MSForEachTable 'EXEC sp_spaceused ''?'''

    SELECT * FROM #SU

    IF OBJECT_ID('tempdb..#su') > 0

     DROP TABLE #su

    GO

  • Very cool, works in 2005 too.

    Thank You

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply