Disk space usage by SQL Server

  • I am trying to build a report for all my SQL Servers. I need to find the total disk usage for each of my servers. I ran the following T-SQL but the results are not accurate:

    CREATE TABLE #files1(

    [dbname] [sysname] NOT NULL,

    [name] [sysname] NOT NULL,

    [physical_name] [nvarchar](260) NOT NULL,

    [int] NOT NULL

    )

    EXEC sp_MSforeachdb '

    insert into #files

    select ''[?]'',name,physical_name,size

    from [?].sys.database_files'

    SELECT [dbname]

    ,[name]

    ,[physical_name]

    ,

    FROM #files1

    I also tried running the following:

    Exec sp_MSForeachDB @command1="use [?]; EXEC sp_spaceused"

    This procedure gives accurate results but I want a single output so I can copy the entire thing in one shot into and excel sheet and so a sum for all databases.

    Does anyone have a better script that will give me the totals?

    Thank you.

    GB

  • Hi,

    You take help of this http://learnmysql.blogspot.in/2012/06/simple-script-to-find-free-space-in-sql.html

    blog...it really helped for me.

    Regards,
    Shivrudra W

  • Thanks Shivrudra. Thank you very much!!! That worked!!!

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

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