触发器实现sql语句:当修改一条数据的某个字段时,其他数据的这个字段的值也改变 5
有一个物流调度单表(logistics_scheduling),每一行都有car_id和car_type字段,当修改某一行的car_type时,将会修改与这一行car_i...
有一个物流调度单表(logistics_scheduling),每一行都有car_id和car_type字段,当修改某一行的car_type时,将会修改与这一行car_id相同的每一行的car_type的值,及car_id和car_type是一一对应关系
在线等,求大神帮帮忙,急~ 展开
在线等,求大神帮帮忙,急~ 展开
1个回答
展开全部
create trigger trigger_logistics_scheduling_cartype_update
on logistics_scheduling
after update
as
if update(car_type)
declare @updated_carID int
declare @updated_carType varchar(50)
begin
set @updated_carID = (select d.car_id from deleted d,inserted i where d.car_id = i.car_id)
set @updated_carType = (select d.car_type from deleted d,inserted i where d.car_id = i.car_id)
update logistics_scheduling
set car_type = @updated_carType
where car_id = @updated_carID
end
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询