如何在插入时创建具有可能 ROUND 值的触发器?
此触发器不起作用:(
CREATE TRIGGER test
ON repaymentevents
AFTER INSERT
AS
BEGIN
SELECT round(value, 2) FROM Inserted
END
如何在插入时创建具有可能 ROUND 值的触发器?
此触发器不起作用:(
CREATE TRIGGER test
ON repaymentevents
AFTER INSERT
AS
BEGIN
SELECT round(value, 2) FROM Inserted
END
正如@marc_s 所说,我认为您需要一个INSTEAD OF
触发器:
CREATE TRIGGER test
ON repaymentevents
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO repaymentevents
SELECT round(SomeValue, 2) FROM Inserted
END
这是你需要的吗?这是空气代码,显然我无法测试,因为我没有你的桌子,但希望你能明白。
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