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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 A generic trigger

Author  Topic 

veggen
Starting Member

1 Post

Posted - 2008-04-11 : 08:15:33
Here's the scenario:
whenever a change (insert/update/delete) has occured in any of the tables, it needs to be logged by adding the changed table's name, and changed columns' names (if any) into the special ChangeLog table.
So, is it possible for me to write a generic trigger that would get the name of the table it just executed upon and names of every column affected by the UPDATE and then insert those into the Log table?
If this is not possible, how do you suggest it should be done?

I'm familiar with standard SQL but T-SQL is completely new to me, so please bear with me if my question makes no sense...

Thanks!

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-04-11 : 09:11:39
personally I'd suggest you do it in SQL2008 instead, which has CDC built in

...otherwise you'll need to write a trigger on every table you want to monitor

Em
Go to Top of Page
   

- Advertisement -