我有两个表,分别是dbo.tb_dept_change和dbo.tb_employee。我需要更改触发器,但它会注意到消息2010,等级16,状态1,过程tb_dept_change,第21行无法对'dbo.tb_dept_change'进行更改,因为它是不兼容的对象类型。
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[tb_dept_change] ON [dbo].[tb_employee]
FOR UPDATE
AS
if ( COLUMNS_UPDATED() &7) >0
BEGIN
if ((select employee_dept from Deleted ) <> (select employee_dept from Inserted))
begin
insert into tb_dept_change
(ch_date)
values(getdate())
update tb_dept_change set ch_source =Deleted.employee_dept, ch_duty_source = Deleted.employee_duty from Deleted
update tb_dept_change set ch_destination = Inserted.employee_dept, ch_duty_Destination = Inserted.employee_duty from Inserted
update tb_dept_change set ch_employee = Deleted.employee_id from Deleted