Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBCC Usage for Auditting

Status
Not open for further replies.

ousoonerjoe

Programmer
Jun 12, 2007
925
US
I've recently learned about the existence of the DBCC calls. From what I am discovering, this has great use in Audit trails. What I am running into, is being able to push the output to a table. Ideally, I just need the 'EventInfo' field, but will take all and work with it as needed. Here's a couple samples of what i've been trying to pull off:
Code:
DECLARE @Id INT;
DECLARE @Et VARCHAR(50);
DECLARE @Parms    INT;
DECLARE @T  VARCHAR(8000);

SET @Id = (SELECT @@SPID);

DECLARE Curse CURSOR FOR DBCC INPUTBUFFER (@Id)
OPEN Curse
FETCH NEXT FROM Curse INTO @Et, @Parms, @T

WHILE @@FETCH_STATUS = 0

      BEGIN

      INSERT INTO TestAudit(EventType, Params, EventInfo)
      VALUES (@Et, @Parms, @T)

      FETCH NEXT FROM Curse INTO @Et, @Parms, @T
      END
CLOSE Curse;
DEALLOCATE Curse;

[i][u]Something like this is out too:[/u][/i]

DECLARE @Id INT;
SET @Id = (SELECT @@SPID);

SELECT (DBCC INPUTBUFFER (@Id)) INTO TestAudit
Any assistance is welcome.

Thank you.

--------------------------------------------------
Bluto: What? Over? Did you say "over"? Nothing is over until we decide it is! Was it over when the Germans bombed Pearl Harbor? No!
Otter: Germans?
Boon: Forget it, he's rolling.
--------------------------------------------------
 
ooops. Placed this in the wrong group.


--------------------------------------------------
Bluto: What? Over? Did you say "over"? Nothing is over until we decide it is! Was it over when the Germans bombed Pearl Harbor? No!
Otter: Germans?
Boon: Forget it, he's rolling.
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top