SQL insert触发器

来源:百度知道 编辑:UC知道 时间:2024/05/16 16:07:03
我想实现的是一个 sql的 insert触发器,它在一个schedule表增加一条记录时执行.然后在另外一个表里更新一个字段.这个触发器怎么写
可否写得详细一点.

CREATE TRIGGER schedule_Insert ON dbo.schedule

FOR INSERT

AS

DECLARE @id Char(4),@ziduan Char(10)

Select @id=id,@ziduan=ziduan from inserted

update baioming set ziduan=@ziduan where id=@id

具体lz根据自己需要修改

update t
set t.field1 = I.field1
from table1 t
inner join inserted I on (t.pk = I.pk)