TheSQLGuru
4/1/2007 6:03:00 PM
Typically for an auditing situation, you insert the appropriate records in
tables with an identical structure as the one being audited (with perhaps a
field or two added for things like date/userid).
Trying to put data from a variety of tables into a single audit table would
entail something like casting every field to a varchar and concatenating
them, or perhaps mashing them into XML and putting them into an XML column.
Not very straight forward activity, and the data may be less than useful
also.
You may wish to take a look at the Audit product from ApexSQL. This will
build out an auditing system for you, with a number of nifty features.
--
TheSQLGuru
President
Indicium Resources, Inc.
"Manny Chohan" <MannyChohan@discussions.microsoft.com> wrote in message
news:FB69DB4B-CD4D-4484-B851-9B066F7DC1C4@microsoft.com...
> Hello,
>
> I have Accounts and Session_History table with following schema:
> Accounts AccountID int PK
> AccountName varchar
> CreateUser varchar
>
> Session_History RecordType char(3) "ACC"
> RecordID int
> "ACCOUNTID"
> UserID varchar
> I have multiple tables in my database i.e contacts, accouts, leads etc. I
> would like to maintain history of what the user does therefore need a
> update,delete and insert trigger to enter data into the session_history
> table.
>
> Can someone please post how to create a trigger to enter record in
> session_History table whenever a record is created, updated or deleted in
> the
> Accounts Table?
>
> Thanks
>
> Manny
>