How to store DBCCresults ?

  • i need to store DBCC results in a table for audit

    for ex:

    Create table Sp_info (Eventtype varchar(50),parameters int,eventinfo nvarchar(max))

    insert into Sp_info

    dbcc inputbuffer(51)

    Can somebody help me ???

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • bhuvnesh.dogra (9/23/2008)


    i need to store DBCC results in a table for audit

    for ex:

    Create table Sp_info (Eventtype varchar(50),parameters int,eventinfo nvarchar(max))

    insert into Sp_info

    dbcc inputbuffer(51)

    Can somebody help me ???

    insert into Sp_info

    EXECUTE('dbcc inputbuffer(51)')

    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
  • hi gila ,

    i need to pass spid as parameter

    so its giving error :

    declare @spid int,@lstr varchar(100)

    set @spid = 52

    set @lstr = 'insert into Sp_info dbcc inputbuffer( ' +cast( @spid as varchar) + ')'

    exec @lstr

    Msg 156, Level 15, State 1, Line 4

    Incorrect syntax near the keyword 'set'.

    please rectify error ???

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • bhuvnesh.dogra (9/23/2008)


    hi gila ,

    i need to pass spid as parameter

    so its giving error :

    declare @spid int,@lstr varchar(100)

    set @spid = 52

    set @lstr = 'insert into Sp_info dbcc inputbuffer( ' +cast( @spid as varchar) + ')'

    exec @lstr

    Msg 156, Level 15, State 1, Line 4

    Incorrect syntax near the keyword 'set'.

    please rectify error ???

    declare @spid int,@lstr varchar(100)

    set @spid = 52

    set @lstr = 'dbcc inputbuffer( ' +cast( @spid as varchar) + ')'

    insert into Sp_info

    exec (@lstr)

    You don't need to make the table column varchar(max). DBCC inputbuffer returns a max of 4000 characters

    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
  • check this link

    http://qa.sqlservercentral.com/Forums/Topic567637-146-1.aspx

    have i provided right answer ????:)

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

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

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