同意楼上的建议: declare @hp_id int set @hp_id = 2 if exists select * from total where hp_id = @hp_id update total set product_quantity = product_quantity + 2, product_inputdate = '2002-10-21' where hp_id = @hp_id else insert into total (hp_id,product_quantity,product_unit, product_inputdate) values (1,2,"台","2002-10-21")
declare @hp_id int
set @hp_id = 2
if exists select * from total where hp_id = @hp_id
update total set product_quantity = product_quantity + 2,
product_inputdate = '2002-10-21'
where hp_id = @hp_id
else
insert into total (hp_id,product_quantity,product_unit, product_inputdate) values (1,2,"台","2002-10-21")