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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-11-22 : 10:03:04
|
| Greg writes "I was wondering if you know if there is a way to capture the column names in the table being triggered? Here is the scenario.I read the article on 4guysfromrolla.com about tracking the history of changes made to records in a database by using triggers. We have tried to do the same thing at my work. But the problem is every trigger has to have every field name hardcoded into it. If a table changes, the triggers all have to be updated with it. If there was a way to know what fields existed in the table you could code the triggers to dynamically detect the fields and then the same code per insert/update/delete trigger would work for all tables. Obviously an insert & delete trigger would need to have all the fields and an update would need to detect which fields were updated.Hope this makes sense.Thanks" |
|
|
GregKats
Starting Member
1 Post |
Posted - 2001-11-29 : 11:23:41
|
Do you have any examples?quote: If you are just using this for auditing or something generic then writ e script to generate the triggers from the tables by accessing information_schema.columns. If you change a table just regenerate the triggers and run the script.You could also find in a generic trigger which field is being updated via the bit map then access use the colid field in syscolumns to log the change to the table/column.==========================================Cursors are useful if you don't know sql.Beer is not cold and it isn't fizzy.
|
 |
|
|
|
|
|