日期:2014-05-18 浏览次数:20665 次
ALTER trigger [dbo].[backup_pending_job_20110120] on [dbo].[_pending_job] after insert as begin declare @var sysname select @var=ltrim(JobID) from inserted insert dbo._pending_job_backup_20110119(JobID,SystemID,Owner,ParentOwner,JobName,URL,IssuedTime,JobType,ActionType,SyncToGMCCPortal,CreateTime,LastUpdate,GMCCPortalID,GMCCAppID) select JobID,SystemID,Owner,ParentOwner,JobName,URL,IssuedTime,JobType,ActionType,SyncToGMCCPortal,CreateTime,LastUpdate,GMCCPortalID,GMCCAppID from _pending_job where JobID=@var end
create trigger insert_In on In_Product
after insert
as
begin
declare @code1 varchar(10) --对inserted中的procode进行判断
select @code1 = procode from inserted
if @code1 not in (select procode from ProductStore) --入库产品在库存表中不存在时
begin
insert into ProductStore select * from inserted
end
else --入库产品在库存中存在时
begin
update ProductStore
set quantity = quantity + (select quantity from inserted where procode = @code1)
end
end
go
------解决方案--------------------