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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logging Origin Table in Audit Trail Trigger

Status
Not open for further replies.

xcaliber2222

Programmer
Apr 10, 2008
70
US
Hello,

I have two tables, each with an audit trail trigger. It is copying two field values I need to the destination (audit) trail table. What I'm not sure how to do is grab the value of the table that the values are actually coming from. If someone could please show me how to do this or point me in the right direction I would really appreciate it.

Here is what I have so far:

CREATE TRIGGER trAuditTrail ON
[dbo].[tbl_Test_1]
FOR INSERT
AS
INSERT [dbo].[tbl_Audit_Trail]
(
claim_number,
source
)
SELECT
clmno,
--source (table)
FROM inserted

Same trigger on [tbl_Test_2]

Thanks,
Alejandro
 
I would never consider putting audit records from different tables in the same audit table. It will become a roadblock on the system. Create separate audit tables for each table you audit. And they should have the name of the user (or application) making the change as well as the date. We usually also save both the old and new values.

"NOTHING is more important in a database than integrity." ESquared
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top