August 13, 2011 at 4:11 am
Hi all,
I am using trigger in TABLE A for update TABLE B with below code
CREATE TRIGGER [dbo].[UpdtMasterFG]
ON [dbo].[RateLog]
FOR Update
As
UPDATE FinishGoods SET
dbo.FinishGoods.CurrentQty1 =(SELECT SUM(dbo.RateLog.Qty1) FROM dbo.RateLog WHERE
dbo.RateLog.StyleNo = dbo.FinishGoods.StyleNo AND dbo.RateLog.ColorID = dbo.FinishGoods.ColorID AND dbo.RateLog.SizeID = dbo.FinishGoods.fldSize)
Its working fine but problem is , it is updating all record (7000 record) of table "FinishGoods". i want to update only those record which i update in "RateLog" Table.
i heard about inserted table but don't know how to use it.
Any help would be appreciable.
Thanks & regards,
Mohammad Yusuf
August 13, 2011 at 8:12 am
The inserted table has the same structure as the table the trigger is on, but only has the rows have been changed. Hence you would probably use it in place of RateLog in the trigger.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 13, 2011 at 8:41 am
Ya those exemples are harder to fin in the documentation (not in create trigger, but burried deep in a link).
http://msdn.microsoft.com/en-us/library/ms190752(v=SQL.90).aspx
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply