0

我需要创建一个触发器,在插入或更新时将当前日期和时间戳保存到行中。

表结构

[Period] [char](7) NOT NULL,
[CompanyAlfaCode] [char](2) NOT NULL,
[SamplePercentaje] [int] NULL,
[Usuario] [varchar](50) NULL,
[Date] [Datetime] NULL,

非常感谢你。

4

1 回答 1

0

也许是这样的:

CREATE TRIGGER DateTrigger ON CompanySampleConfig
AFTER INSERT,UPDATE
AS
BEGIN
  UPDATE CompanySampleConfig SET [Date] = current_timestamp
  WHERE EXISTS
  (SELECT '' FROM inserted
  WHERE CompanySampleConfig.[Period] = inserted.[Period]
    AND CompanySampleConfig.[CompanyAlfaCode] = inserted.[CompanyAlfaCode]
END
于 2012-05-22T16:51:32.203 回答