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 |
|
Mondeo
Constraint Violating Yak Guru
287 Posts |
Posted - 2007-11-15 : 07:24:23
|
| How do I write a trigger so that when a row is updated or inserted,If FieldA = True Then FieldB = TrueIf FieldB = False Then FieldB = FalseThanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-15 : 07:28:10
|
[code]UPDATE tSET FieldB = CASE WHEN i.FieldA = 1 THEN 1 WHEN i.FieldB = 0 THEN 0 ELSE i.FieldB ENDFROM TABLE t INNER JOIN inserted i ON t.pk = i.pk[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|