Piping the Results of a DBCC statement into a table...

  • Are there any easy techniques to allow the results of a DBCC statement to be inserted directly into a table.  I run a DBCC Showcontig overnight at the weekends, on a Database with a large number of tables and subsequent indexes.  What I would like to be able to do is to pipe the results of this DBCC every week into a table which I can then query.  I will write a DTS job if neccessary, to extract the info from the text file output, but wondered whther anyone had come across a solution previously that I am not aware of.

    Would welcome any suggestions....

  • Well hopefully an article I wrote will appear in the SQLCentral mag next month (Brian I figure your busy, but I haven't heard back.  Although I am having major e-mail problems at home).

    It captures and saves information, mainly on DB and table space usage and utilization.  The code will probably be posted up here somewhere.   So if you will either post or send me the code you develop for the contig, it is on my list, here's a snippet that should get you going

    CREATE TABLE #DBInfo

    (

    DBName VarChar(100) not null PRIMARY KEY CLUSTERED,

    DBSize Dec (15, 2),

    DBAlloc Dec (15, 2),

    DBInUse Dec (15, 2),

    LogSize Dec (15, 1),

    LogPercent Dec (8, 4),

    Status Int,

    DBNotes VarChar (50)

    )

    INSERT #DBInfo ( DBName, LogSize, LogPercent, Status )

    EXEC ('DBCC SQLPERF(logspace) WITH no_infomsgs')

     


    KlK

  • Run DBCC Showcontig with TABLERESULTS option. See example E. in BOL.

  • Thanks guys... I intend to write a script using the TableResults option, to build a table for the purposes of producing exactly what Im after.

    Thanks again.

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

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