create trigger Insert_emp on dbo.emp
after insert
as
begin
declare @tablename varchar(50)
declare @rdatetime varchar(20)
declare @month int
set @rdatetime = (select Bdate from inserted)
set @month = (select datepart(mm,@rdatetime))
case when @month = 2 then set @tablename = 'FEP_EMP' end
print @tablename
end
触发器将在 emp 表中插入记录之后执行。它将选择插入的日期。从该日期开始计算月份。我想要设置表名的值。