Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Auditing table' data except some of column changes

Author  Topic 

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2014-09-26 : 03:58:15
Hi,

assume we have 5 columns in a table. while auditing updated data i need to log data except some of the columns.

Create table Test( col1 int, col2 int, col3 int, col4 int, col5 int)

if any of the columns in (col2 and col3) updated, no need to log those changes to audit table; we can achieve this by using UPDATE( col2) or UPDATE ( col3) checking.. But i have to log the changes if any of other columns (col1m col4 or col5) changed along with col2 or col3
...

please advise

--
Chandu

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2014-09-26 : 08:09:52
Check these cases
update(col1) corresponding auditing
update(col4) corresponding auditing and
update(col5) corresponding auditing

then if u tried to update both col2 and col5 then 3rd message will be triggered.



M.MURALI kRISHNA
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2014-09-26 : 08:26:09
Yes, i did the same earlier...

What if the table is altered to add new columns and have too many columns ? then we should change the trigger as well. This approach will take too many code changes...

Any other solution?

--
Chandu
Go to Top of Page
   

- Advertisement -