我試圖創建觸發器:觸發器,可以登錄每一個INSERT變更,刪除
CREATE TRIGGER DataTrigger ON Data AFTER INSERT , DELETE
AS
BEGIN
IF EXISTS(SELECT * FROM Inserted)
INSERT INTO [dbo].[AuditTrail]
([ActionType]
,[TableName]
,[Name]
,[Time])
('INSERT' //Incorrect syntax near 'INSERT'
,'Data'
,SELECT col1 FROM Inserted
,CURRENT_TIMESTAMP //Incorrect syntax near the keyword 'CURRENT_TIMESTAMP')
END
,但它一直在說,我有thoes錯誤,有人可以告訴我,我做錯了什麼?
P/S:檢測更新的最佳方法是什麼? 謝謝
不需要IF EXISTS(SELECT * FROM插入)中的語句,我們呢? – Xitrum