Hi
I was having a requirement to generate report for work done by user on daily basis and the details of actions (Insert/Update/Delete) by user. Initially i was using ICaptureLogRow but i have so many table and i have to create a copy of each table and a log class for each module. My table also changed frequently so maintaining log table and log class was becoming pain for me. So i created custom behaviour to log all changes in single table.
I am sharing code by thinking that it may be helpful for someone else.
DBScripts for Table, Stored Procedure and Code file is attached.
DB Scripts
SQLServer_AuditScript.txt
Code File
AuditBehavior.txt
How To Use
public sealed class UserRow : LoggingRow, IIdRow, INameRow, IIsActiveRow, IAuditLog
{
}
public sealed class UserRow : LoggingRow, IIdRow, INameRow, IIsActiveRow, IExAuditLog
{
public Int32Field UserId
{
get { return Fields.IdField; }
}
}
Here is screenshot of log table

Hope this will be helpful for someone. Please let me know if you find any improvement in this or have any suggestions.
Thanks for sharing @ramveersgh. How do you know which row got deleted (Could field values be saved before deleting the row)?
P.S: Could you move this thread to the Wiki?
@awesomegithubusername
I am inserting primary key in the log table for deleted row. Off course this primary key will have log for insert and updated too. So RowId is enough to have for delete log. I have attached an image for the log with Insert, Update and Delete.
I never created any page on wiki but i will try to add it in Wiki if @volkanceylan verify and allow me to add this.
Thanks for sharing @ramveersgh. Actually yours is similar to AuditLog but i didn't test it for long time. You should share your solution in wiki. Another option is SQL Server Change Data Capture (CDC).
Thanks @volkanceylan
I also thought that IAuditLogRow should be similar to what i did. I will share my solution to wiki and will close this.
I am using SQL Express version which does not support CDC.
Added the Wiki Page for this.
Wiki Page
Good job @ramveersgh. Much appreciated.
Thanks @awesomegithubusername !!
Most helpful comment
Added the Wiki Page for this.
Wiki Page