alter trigger material_trigger
on tb04_material for insert
as
begin
declare @materialId int
select @materialId=i.material_id from inserted i
declare @G_StatisticsId int
exec @G_StatisticsId = sp_GetUniqueID 'tb04_statistics',@G_StatisticsId
declare @dateNow datetime
declare @year int
declare @month int
set @dateNow=getdate()
set @year=year(@dateNow)
set @month=month(@dateNow)
insert into tb04_statistics(id,year,month,begin_value,end_value,material_id)
values(@G_StatisticsId,@year,@month,0,NULL,@materialId)
end
on tb04_material for insert
as
begin
declare @materialId int
select @materialId=i.material_id from inserted i
declare @G_StatisticsId int
exec @G_StatisticsId = sp_GetUniqueID 'tb04_statistics',@G_StatisticsId
declare @dateNow datetime
declare @year int
declare @month int
set @dateNow=getdate()
set @year=year(@dateNow)
set @month=month(@dateNow)
insert into tb04_statistics(id,year,month,begin_value,end_value,material_id)
values(@G_StatisticsId,@year,@month,0,NULL,@materialId)
end
转载于:https://www.cnblogs.com/zhuxiongfeng/archive/2009/11/26/1611550.html
最后
以上就是务实朋友最近收集整理的关于一个简单的SQL SERVER insert触发器的全部内容,更多相关一个简单的SQL内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复