Triggers Update SQL Server
How Create Trigger For Update Items in Invoice and decrement in Table Items
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Anupam SinghRank #643 · 3.7K reputationPosted May 13, 2014, 8:31 PM EDT
Refer this link will definitely help you.
Jignesh TrivediRank #16 · 50.3K reputationPosted May 13, 2014, 9:28 PM EDT
hi,
like
CREATE TRIGGER trg1
ON tableName
UPDATE
AS
BEGIN
// write here TSQL
Select * from table
END
also refer below link for more detail
http://msdn.microsoft.com/en-us/library/ms189799.aspx
hope this will help you.
Nitesh KejriwalRank #253 · 9.9K reputationPosted May 13, 2014, 10:40 PM EDT
The below trigger will run whenever an item is updated on Invoice table. However, the exact implementation depend on your table structure. CREATE TRIGGER trgAfterUpdate ON [dbo].[Invoice] FOR UPDATE AS declare @ItemID int; declare @ItemCnt int; select @ItemID = i.ItemID from inserted i; select @ItemCnt = i.Itemcnt from inserted i; UPDATE Items SET ItemStock = ItemStock-@ItemCnt WHERE ItemID = @ItemID GO