Hi,

I had two columns in Master table (Employee) id,name
In My Audit table(Employee_Audit) i have to insert record with id, name, date

What's the problem is,..
I want to get the old data before the field gets updated,..

Ex: Employee
id name
1 Ram

i had changed to 2 krishna
But i want the entry in Employee_Audit table as
1 Ram 16/09/2010.. ( the old value of the record before updated)

Can anyone help me?

-chandru

One way to do this is to start a transaction, insert into the audit table, then do the update. By using a transaction, you ensure that both changes are made successfully, or nothing happens at all (don't want an audit record when there is no change, or a change when you can't create an audit record.

You can do this either in C# code, or by using a stored procedure. There is no need to actually fetch the old data first, just insert it directly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.