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-19 : 07:56:42
|
| Shelly writes "I need to write a trigger that will respond to an update statement. If a particular field was updated, I need to act on that info. How do I tell whether a particular field was updated or not?" |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2004-11-19 : 08:07:53
|
| Just create an update trigger and use IF UPDATE (column) |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-11-19 : 08:22:49
|
Won;t IF UPDATE (column) return TRUE if the column is changed in ANY of the records passed to the trigger?PerhapsSELECT *FROM MyTable T LEFT OUTER JOIN deleted D ON D.MyPK = T.MyPKWHERE D.MyPK IS NULL -- New record OR T.MyColumn <> D.MyColumn OR (T.MyColumn IS NULL AND D.MyColumn IS NOT NULL) OR (T.MyColumn IS NOT NULL AND D.MyColumn IS NULL) is needed to identify rows that a change in that specific columnNote that this will catach a new record where MyColumn = NULL - which maynot be requiredKristen |
 |
|
|
|
|
|