0

如何在插入时创建具有可能 ROUND 值的触发器?

此触发器不起作用:(

CREATE TRIGGER test
   ON repaymentevents
   AFTER INSERT
AS
BEGIN
    SELECT round(value, 2) FROM Inserted 
END
4

2 回答 2

1

正如@marc_s 所说,我认为您需要一个INSTEAD OF触发器:

CREATE TRIGGER test
   ON repaymentevents
   INSTEAD OF INSERT
AS
BEGIN
    INSERT INTO repaymentevents
    SELECT round(SomeValue, 2) FROM Inserted 
END

这是一个例子。

于 2012-08-24T20:35:32.120 回答
0

这是你需要的吗?这是空气代码,显然我无法测试,因为我没有你的桌子,但希望你能明白。

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
于 2012-08-24T20:33:57.343 回答