SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Triggers for insert,update,delete in SQL server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mkfrns
Starting Member

2 Posts

Posted - 12/09/2013 :  12:17:22  Show Profile  Reply with Quote
I have created audit table

CREATE TABLE Test_Audit
(column_name varchar(50),
old_value varchar(100),
new_value varchar(100),
Table_name varchar(100),
Username varchar(100),
action varchar(100),
Audit_Timestamp datetime
)

and I have table named testing
create table testing
(number int, name varchar(10))

I want trigger for insert,delete,update for table testing and the entries should be added to Test_Audit..I want the old values,new values,column name to be displayed in Audit table..

My trigger only works with 1 column table.If i run for 2 column table,the latest modified column is updated in oldvalue and new value..but actually 2 values should get updated in oldvalue and new value for 2 columns table

could anyone please help me with the queries??Your help is appreciated

Edited by - mkfrns on 12/09/2013 12:31:42

Lamprey
Flowing Fount of Yak Knowledge

4612 Posts

Posted - 12/09/2013 :  12:32:36  Show Profile  Reply with Quote
Here are some links of how to set up audit triggers:
http://www.softcodearticle.com/2012/11/imlementing-generic-audit-trail-trigger-in-sql-server/
http://gallery.technet.microsoft.com/scriptcenter/Create-Audit-Table-and-5cd69d5d

Here is a link to how to setup Auditing in the DB itself:
http://bradmcgehee.com/2010/03/30/an-introduction-to-sql-server-2008-audit/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000