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 |
jrockfl
Posting Yak Master
223 Posts |
Posted - 2008-01-19 : 15:01:14
|
I want to update User_Def with the current value from Sales_PTD before that column is updated. How does this trigger look? It appears to work fine, just wanted a second set of eyes to look over it.CREATE TRIGGER UpdateSalesON SalesFOR UPDATEASBEGIN UPDATE Sales SET User_Def = d.Sales_PTD FROM deleted d INNER JOIN inserted i on i.id = d.id WHERE d.id = sales.idEND |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2008-01-19 : 15:33:17
|
that looks fine. only modification i might suggest is to join to sales, may be better if more than one record is updatedCREATE TRIGGER UpdateSalesON SalesFOR UPDATEASBEGINUPDATE SalesSET User_Def = d.Sales_PTDFROM deleted dINNER JOIN inserted i on i.id = d.id INNER JOIN Sales sOn S.id = d.id--WHERE d.id = sales.idEND |
 |
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2008-01-19 : 16:04:44
|
Thanks russel,I will give that a try |
 |
|
|
|
|