Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1640

Re: Need example showing how to log DML events for a table

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Need example showing how to log DML events for a table
Date 2013-12-31 22:03 +0100
Organization Erland Sommarskog
Message-ID <XnsA2A7E0513E885Yazorman@127.0.0.1> (permalink)
References <l9taut$1rh$2@dont-email.me> <XnsA2A76D973EE1CYazorman@127.0.0.1> <l9vb0r$jbd$1@dont-email.me>

Show all headers | View raw


JoeM (noreply@replytogroup.com) writes:
> That's very useful information - thanks for posting that.  In 
> the audit table, is there a way to include the actual DML 
> (delete, or insert, or update) statement that was executed?
> 

Yes and no. You can use the command DBCC INPUTBUFFER for this purpose, but

1) It requires high permissions, even for your own spid. This can be 
addressed with certificate signing, but given the next points, I don't think
it's worth the hassle.

2) If the DML statement was executed inside a stored procedure, you will 
only see the call to the stored procedure.

3) If the application uses parameterised statements (which it should), you 
will only see the parameter names.



-- 
Erland Sommarskog, Stockholm, esquel@sommarskog.se

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Need example showing how to log DML events for a table JoeM <noreply@replytogroup.com> - 2013-12-30 18:42 -0800
  Re: Need example showing how to log DML events for a table Erland Sommarskog <esquel@sommarskog.se> - 2013-12-31 10:46 +0100
    Re: Need example showing how to log DML events for a table JoeM <noreply@replytogroup.com> - 2013-12-31 12:56 -0800
      Re: Need example showing how to log DML events for a table Erland Sommarskog <esquel@sommarskog.se> - 2013-12-31 22:03 +0100
        Re: Need example showing how to log DML events for a table JoeM <noreply@replytogroup.com> - 2013-12-31 13:33 -0800

csiph-web