Return One Field/One Row - DBCC SQLPERF(logspace)

  • I am using a monitoring system where I can monitor a numeric SQL result assuming the result is one field and one row.

    I would like to do this to say monitor the free available space or percentage on say the Master database. DBCC SQLPERF gives me a few columns and results for all databases on the server.

    Any ideas ?

  • Create a temp table, insert the results of the DBCC into there (use EXEC (DBCC...) ), then select from the temp table.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I'd use a query something like this:

    SELECT

    size * 8 / 1024.0 -

    FILEPROPERTY(database_files.name, 'SpaceUsed') * 8.0 / 1024 AS free_space_mb

    FROM

    sys.database_files

    The query returns the data for the database context it is executed in.

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

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