当我收到错误消息“Msg 156, Level 15, State 1, Procedure defectTrigger, Line 15 Incorrect syntax near the keyword 'Set'”时,我正在尝试按如下方式创建触发器。
代码如下。你能告诉我是什么导致了错误。
use [DM]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Trigger defectTrigger on dbo.tcefed
FOR INSERT
AS
declare @defID int;
declare @clientID int;
declare @defLog varchar(200);
declare @datatime datetime;
declare @status varchar(50);
declare @project varchar(50);
select @clientID=i.ClientID from inserted i;
select @defID=i.DefectID from inserted i;
select @project=i.ProjectCode from inserted i,
Set @defID = 'insert into dbo.DefectLog values(@clientID,@project,@defID)'
GO