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 |
|
rmrper99
Starting Member
29 Posts |
Posted - 2006-05-24 : 21:42:24
|
| I am new to triggers and I have read BOL but I don't understand. What I am trying to do I think is rather simple. If the STATUS field changes to R, then I want to update that record by putting "rejected" in the USER1 field. Can someone help me? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-24 : 21:45:31
|
Place this in your update triggerupdate uset USER1 = 'rejected'from inserted i inner join table uon i.pk = u.pkwhere i.STATUS = 'R' KH |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-05-24 : 22:37:40
|
why not do the update of user1 in your update query instead? --------------------keeping it simple... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-25 : 04:10:45
|
| If R stands for Rejected, then no need of updating it. In select statement useSelect columns, case when User1='R' then 'Rejected' end from yourTableMadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-25 : 04:43:44
|
adjusting minor typo errSelect columns, case when User1 STATUS = 'R' then 'Rejected' end as USER1 from yourTable KH |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2006-05-25 : 04:58:35
|
If you use that approach, then you should probably catch the rest of the possibilities -Select columns, case when STATUS = 'R' then 'Rejected' else user1 end as USER1 from yourTable -------Moo. :) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-25 : 05:14:12
|
quote: Originally posted by khtan adjusting minor typo errSelect columns, case when User1 STATUS = 'R' then 'Rejected' end as USER1 from yourTable KH
Thanks for the correctionMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|