【Vegas原创】实现两个table人员同步的触发器
CREATE TRIGGER [TR_ADDNEW_TO_QCC] ON dbo.AM_EMPLOYEE
FOR INSERT
AS
SET XACT_ABORT ON
declare @emp_no nvarchar(10)
declare @dept_code nvarchar(10)
declare @emp_name nvarchar(20)
declare @logonid nvarchar(50)
declare @email nvarchar(100)
declare @ext_no nvarchar(50)
declare @org_id nvarchar(50)
declare @site_name nvarchar(50)
declare @active nvarchar(1)
declare @company nvarchar(3)
select @emp_no = inserted.[emp_no],@emp_name = inserted.[emp_name],@logonid = inserted.[login_name],@email = inserted.[mail_account],@org_id = inserted.[dept_code], @ext_no = inserted.[ext_no],@active = inserted.[active], @site_name = inserted.[site_code],@company=inserted.[site_code]
from inserted
IF update([login_name])
begin
insert into auuserlist
values(@emp_no,@emp_name,@logonid,@email,@ext_no,@org_id,'','','','','1','','',@site_name,@company,@active)
end
FOR INSERT
AS
SET XACT_ABORT ON
declare @emp_no nvarchar(10)
declare @dept_code nvarchar(10)
declare @emp_name nvarchar(20)
declare @logonid nvarchar(50)
declare @email nvarchar(100)
declare @ext_no nvarchar(50)
declare @org_id nvarchar(50)
declare @site_name nvarchar(50)
declare @active nvarchar(1)
declare @company nvarchar(3)
select @emp_no = inserted.[emp_no],@emp_name = inserted.[emp_name],@logonid = inserted.[login_name],@email = inserted.[mail_account],@org_id = inserted.[dept_code], @ext_no = inserted.[ext_no],@active = inserted.[active], @site_name = inserted.[site_code],@company=inserted.[site_code]
from inserted
IF update([login_name])
begin
insert into auuserlist
values(@emp_no,@emp_name,@logonid,@email,@ext_no,@org_id,'','','','','1','','',@site_name,@company,@active)
end
喜欢请赞赏一下啦^_^