Database Auditing (Urgent)
-
Dear all, I have the following case: In a SQL db, each time a row is changed in a specific table ( say OriginalTable ) i need to insert a row for each changed column in a specific table say ( HistoryTable ) by the following values: 1- The OriginalTable Column name ( i.e. the column that its value is changed ) 2- The Old value ( existing before the update process ) 3- The New value ( existing after the update process ) I dont know if this can be done using SQL or programmatically from the code. Plz, if anyone know the solution of that problem using any SQL or Code reply me as soon as possible. ( Note : my application is an ASP.Net project) thank u all Rania Adel
-
Dear all, I have the following case: In a SQL db, each time a row is changed in a specific table ( say OriginalTable ) i need to insert a row for each changed column in a specific table say ( HistoryTable ) by the following values: 1- The OriginalTable Column name ( i.e. the column that its value is changed ) 2- The Old value ( existing before the update process ) 3- The New value ( existing after the update process ) I dont know if this can be done using SQL or programmatically from the code. Plz, if anyone know the solution of that problem using any SQL or Code reply me as soon as possible. ( Note : my application is an ASP.Net project) thank u all Rania Adel
You can use an SQL TRIGGER to create these records automatically whenever a modification is performed. (see CREATE TRIGGER in the SQL documentation). Also, you can use the COLUMNS_UPDATED() function to determine which columns have been changed (in order to produce the text for the column name). Hope this helps. Regards, Alex