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 |
|
SQLError
Yak Posting Veteran
63 Posts |
Posted - 2005-03-06 : 14:46:27
|
| Hi, when a record in my table is updated, I have the following trigger:---UPDATE Corrections SET LastModified = GetDate() WHERE RecordID = RecordIDSelect RecordID from deleted----What this does though, is update all the columns in the tablebecause of the "RecordID = RecorID" statement. I tried changing Select RecordID as R from Deletedbut this did not work.Can someone help me out.thanks. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-03-06 : 14:56:22
|
| You have two unconnected statements here. One doing an update (of all rows) then one returning a resultset.UPDATE Corrections SET LastModified = GetDate() WHERE RecordID in (Select RecordID from deleted)or betterUPDATE Corrections SET LastModified = GetDate() from Corrections cjoin deleted don d.RecordID = c.RecordID==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
SQLError
Yak Posting Veteran
63 Posts |
Posted - 2005-03-06 : 14:58:57
|
| Thank you very much. |
 |
|
|
|
|
|