我有两张表INVENTORY
和INPUT
create table INPUT(
PRODUCTID nvarchar(10),
QUANTUMINPUT int
)
create table INVENTORY(
PRODUCTID nvarchar(10),
QUANTUM int,
QUANTUMINPUT int,
LASTQUANTUM int
)
当插入列trigger
,表QUANTUMINPUT
转换时,如何在SQL上创建SQL INVENTORY
?
答案 0 :(得分:1)
Create trigger tr_update_insert_input
On dbo.[input]
After insert, update
As
Begin
Set nocount on;
Update intry
Set intry.quantumnput = inpt.quantuminput
From inventory intry inner join inserted inpt
On intry.productid = inpt.productid
End