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 |
|
t1g312
Posting Yak Master
148 Posts |
Posted - 2004-08-15 : 08:07:06
|
| Hi all,I have a timestamp column in my table that I update everytime a change is made to the record using a SP. I use this column for record locking purposes. I also have an audit trail trigger (thanks to nr!) that fires whenever data has been changed. The problem is that there is a slight time difference between the timestamps in the SP and the trigger. Can I make the same timestamp available for the trigger that is used in the SP?ThanksAdi-------------------------/me sux @sql server |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2004-08-15 : 13:11:47
|
| Just modify Nigels trigger to make @UpdateDate be the timestamp value from from #ins or #del. Or you can set the insert statement to point to the timestamp column in the calling table. |
 |
|
|
t1g312
Posting Yak Master
148 Posts |
Posted - 2004-08-16 : 00:31:18
|
| Thanks!Adi-------------------------/me sux @sql server |
 |
|
|
t1g312
Posting Yak Master
148 Posts |
Posted - 2004-08-16 : 01:31:33
|
| Do you mean select @UpdateDate = UpdateDate from inserted/deleted? What about if it is an update?Adi-------------------------/me sux @sql server |
 |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2004-08-16 : 02:03:48
|
| Update = Delete + Insert. So both "magic" tables are populated during an update. Pick the one that suits you best, I reckon the timestamp value in Inserted would be closest to your requirements.OS |
 |
|
|
t1g312
Posting Yak Master
148 Posts |
Posted - 2004-08-16 : 03:31:41
|
| Thanks for that OS!Adi-------------------------/me sux @sql server |
 |
|
|
t1g312
Posting Yak Master
148 Posts |
Posted - 2004-08-16 : 03:41:14
|
| It works brilliantly! Thanks guys!Adi-------------------------/me sux @sql server |
 |
|
|
|
|
|