none
Output parameters for dbcc sqlperf(logspace)

    Question

  • Hi,

    When I run dbcc sqlperf(logspace) command, I get 4 output columns in SQL Query window. But is there a way to specifiy the output parameters while executing this command?

    For example: -

    declare @a varchar(50)
    EXEC '<sqlquery>' @a=@a output

    Can I use above syntax for DBCC queries?

    Thanks
    - JL
    Monday, April 27, 2009 12:23 PM

Answers

  • Hi Jilu,

    You can wrute query as:

    DECLARE @t TABLE(DataBaseName VARCHAR(100), LogSize NUMERIC(18,4), LOgPercentage NUMERIC(18,4), Status INT)
    INSERT INTO @t
    EXEC('DBCC sqlperf(logspace)')

    SELECT *
    FROM @t

    Let me know if it helps you.

    Thanks,
    Tejas Shah
    SQL YOGA
    • Marked as answer by JiLu Monday, April 27, 2009 1:02 PM
    Monday, April 27, 2009 12:50 PM

All replies


  • I hope this can work.
    CREATE
    PROC getLog
    AS
    DECLARE
    @sql NVARCHAR(4000)
    SET @sql=' DBCC SQLPERF(LOGSPACE)'
    EXEC (@sql)
    GO
    CREATE PROC getDatabaseLogspace
    @DatabaseName
    VARCHAR(50)
    AS
    DECLARE
    @Table TABLE
    (DatabaseName VARCHAR(50),LogSize FLOAT, LogSpaceUsed FLOAT(5),Status BIT)
    INSERT INTO @Table
    EXEC getLog
    SELECT * FROM @Table
    WHERE DatabaseName=@DatabaseName
    ------Get the result by giving Parameter
    EXEC getDatabaseLogspace 'master'

    Thanks
    Ramesh.M

    Monday, April 27, 2009 12:44 PM
  • Hi Jilu,

    You can wrute query as:

    DECLARE @t TABLE(DataBaseName VARCHAR(100), LogSize NUMERIC(18,4), LOgPercentage NUMERIC(18,4), Status INT)
    INSERT INTO @t
    EXEC('DBCC sqlperf(logspace)')

    SELECT *
    FROM @t

    Let me know if it helps you.

    Thanks,
    Tejas Shah
    SQL YOGA
    • Marked as answer by JiLu Monday, April 27, 2009 1:02 PM
    Monday, April 27, 2009 12:50 PM