A little rusty at the triggers I see, but here is what I got:
CREATE TRIGGER dbo.MyTest ON dbo.UserTime AFTER INSERT AS
DECLARE @UserTimeProjID Int , @OrderProjID Int, @InternalCostAdd
Int,@ActualHours Int
Select @UserTimeProjID, @OrderProjID, @InternalCostAdd,@ActualHours
(
SELECT UT.ProjectID, Orders.ProjectID, UR.UserRate * UT.ActualHours ,
UT.ActualHours
FROM Orders INNER JOIN
UserTime UT ON Orders.OrderID = UT.OrderID INNER
JOIN
UserRates UR ON UT.UserID = UR.UserID AND
UT.UserTimeID = @@IDENTITY
)
UPDATE ProjectCosts
SET InternalCost = ProjectCosts.InternalCost + @InternalCostAdd,
ActualHours = ProjectCosts.ActualHours + @ActualHours
WHERE ProjectID = @UserTimeProjID
OR ProjectID = @OrderProjID
go
I am not sure if the @@identity works for the inserted row and if my
select statement is correct. Any pointers?
Robert Bailey
Software Engineer
813-230-9967 \\ mobile
[EMAIL PROTECTED]
www.recruitmax.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Protect your mail server with built in anti-virus protection. It's not only
good for you, it's good for everybody.
http://www.houseoffusion.com/banners/view.cfm?bannerid=39
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189869
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54