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 - 2004-11-16 : 07:03:09
|
| Ger writes "Hello there..Little question,I want to update a field(usr_date_modified) in a record in a table(tbl_user) with the date and time when this record has been modified.I therefore want to use a n AFTER UPDATE trigger.But when I use the trigger it updates that field in ALL records in that table instead of only the record that has been modified. Could you please tell em what I am doing wrong? or forget?The code I used is listed below.Thanks in AdvanceGer SuverkroppSET QUOTED_IDENTIFIER ON GOSET ANSI_NULLS ON GOALTER TRIGGER tr_aft_upd_tbluserON dbo.tbl_userAFTER UPDATEASUPDATE tbl_userSET usr_date_modified=GETDATE()WHERE usr_id=usr_idGOSET QUOTED_IDENTIFIER OFF GOSET ANSI_NULLS ON GO" |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2004-11-16 : 10:00:35
|
| [code]UPDATE tbl_userSET usr_date_modified=GETDATE()WHERE usr_id in (select usr_id from inserted)[/code] |
 |
|
|
gesus
Starting Member
1 Post |
Posted - 2004-11-18 : 06:40:11
|
quote: Originally posted by LarsG
UPDATE tbl_userSET usr_date_modified=GETDATE()WHERE usr_id in (select usr_id from inserted)
Thanks a lot!Works fine now.. |
 |
|
|
|
|
|