SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to maintain Audit history during Update Operation


How to maintain Audit history during Update Operation

Author
Message
sharonrao123
sharonrao123
SSC Veteran
SSC Veteran (284 reputation)SSC Veteran (284 reputation)SSC Veteran (284 reputation)SSC Veteran (284 reputation)SSC Veteran (284 reputation)SSC Veteran (284 reputation)SSC Veteran (284 reputation)SSC Veteran (284 reputation)

Group: General Forum Members
Points: 284 Visits: 205
Hi All,

Can you please give me some suggestions on how I can maintain a Audit history during row updates?

I am doing a project which involves the User updating the Cost for each product using the Online User Interface.

When the user hits the Update button I need to copy the Product Key, old value with an start and end date into a history table including the Active Directory login.

And this information will be used in the Product cube to show how the cost has changed during the time and also to calculate the Revenue based on the cost during that time.

I am also wondering if it is best to maintain the Audit history in a different table or use the same Product table and just insert a row with end date time stamp for the old value and create a new row for the updated value.

Please give me your valuable suggestions on how to go about it, which way would be best since the update will happen using an Web User Interface.

Best Regards, Shilpa.
Eugene Elutin
Eugene Elutin
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11654 Visits: 5478
As you have mentioned about using the audit data for building cube, I would recommend to create a dedicated table to keep all audit history of Product changes.
Then you can create an audit trigger (for Update, Insert and Delete), which will copy all Product data from Product table together with some required audit details (eg. date change, user info etc.) into "Product_Audit" table whenever any data modification is performed in Product.

There is another way to track changes in SQL Server you ight consider. It's called CDC (Change data Capture). Have a look it too. However I think audit triggers are more convinient for futher use in building cubes.

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
sharath.chalamgari
sharath.chalamgari
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1942 Visits: 798
There is a nice article on CDC from Pinal


https://www.simple-talk.com/sql/learn-sql-server/introduction-to-change-data-capture-%28cdc%29-in-sql-server-2008/


i would recomend using of history table and some after triggers to use it in your db to track the changes.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search