Reputation: 237
How to create trigger with possibility ROUND value on insert?
This trigger do not work :(
CREATE TRIGGER test
ON repaymentevents
AFTER INSERT
AS
BEGIN
SELECT round(value, 2) FROM Inserted
END
Upvotes: 0
Views: 312
Reputation: 70638
As @marc_s said, I think that you need an INSTEAD OF
trigger:
CREATE TRIGGER test
ON repaymentevents
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO repaymentevents
SELECT round(SomeValue, 2) FROM Inserted
END
Upvotes: 1
Reputation: 781
Is this what you need? This is air-code, obviously I cannot test as I don't have your tables, but hopefully you get the idea.
CREATE TRIGGER test
ON repaymentevents
AFTER INSERT
AS
BEGIN
UPDATE repaymentevents
INNER
JOIN INSERTED I
ON I.id = repaymentevents.id
SET value = round(i.value, 2)
END
Upvotes: 0