Database space used

  • Hi,

    I need to know the total space used by a database..

    How do i insert the results of 'EXEC SP_SPACEUSED' into a table, since it results in two tables?

    Thanks.

  • You'll be better off writing your own SELECT statements against the DMVs to get only the information you really want. Here is a good place to start:

    USE master

    GO

    EXEC sys.sp_helptext

    @objname = N'sp_spaceused'

    GO

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Thanks for the tip! 😉

  • You can also go after the data files, summing the number of 8K pages used and converting to your unit of choice (MB in this example):

    select sum(fileproperty(df.name,'SpaceUsed'))*8./1024.0 as 'Space Used [MB]'

    from sys.database_files df where [type]= 0

  • Thanks! 🙂

Viewing 5 posts - 1 through 4 (of 4 total)

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