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 |
|
azim
Starting Member
29 Posts |
Posted - 2005-02-14 : 06:02:42
|
| I want to update balance on tblProducts from tblInventory_Detbut this Trigger does't workI update the dataset from Datagridplease help[CODE]CREATE TRIGGER UpdateBalance_In ON dbo.tblInventory_DetFOR UPDATE,INSERT,DELETEASBEGIN UPDATE tblProductsSET Balance =Balance + Inserted.InQuantity FROM tblInventory_Det INNER JOIN Inserted ON (tblInventory_Det.ProductID = Inserted.ProductID)Where tblProducts.ProductID=tblInventory_Det.ProductIDEND[/CODE]azim |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-02-14 : 06:08:35
|
| just UPDATE tblProducts SET Balance = tblProducts.Balance + Inserted.InQuantity FROM tblProducts join inserted on tblProducts.ProductID=Inserted.ProductIDThat trigger should probably be for insert only as it doesn't reverse for deletes and doesn't deal with the old amount for updates.==========================================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. |
 |
|
|
|
|
|