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 |
|
CLages
Posting Yak Master
116 Posts |
Posted - 2004-08-11 : 20:30:49
|
| I have a table with (in this sample) 3 columnsMaintable Code Name Date123 ppppp yyyy124 rrrrr wwwwLogtable User Seq Code Name Date Mary 1 123 xxxx yyyymary 2 124 zzzz wwwweach time that mainTable is Updated, I want to get all Columns Before Changes and Insert in a LogTable adding the UserName and seq.in this case Name of code 123 was changed to ppppp then in Logtablei have the OldName and who did the changes.how to do this in a table with many columns?TksCarlos LagesNetcobol + SQL + Cristalwww.adtoos.com |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2004-08-11 : 20:45:48
|
| Have a read up on triggers in Books Online. They will do exactly what you need. |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-08-12 : 11:04:13
|
| You'll want an UPDATE trigger. You will take the results from the deleted table and put them into your new table with the UserName and seq number. Like timmy said, Books Online gives you a great example of this. You should be able to just cut/paste/modify.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|