创建触发器时出错

时间:2013-10-07 12:33:05

标签: sql-server triggers

当我收到错误消息“Msg 156,Level 15,State 1,Procedure defectTrigger,Line 15时,我试图按如下方式创建触发器 关键字“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

0 个答案:

没有答案