SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create TRIGGER [dbo].[Tri_PICKING_Cbtes] ON [dbo].[PICKING_Cbtes]
AFTER UPDATE
AS
    DECLARE @id_trans_origen INT
    SET @id_trans_origen = (SELECT I.Id_Trans FROM Inserted I)

    UPDATE CBTES SET ID_ESTADO_CBTE = 31 WHERE ID_TRANS = @id_trans_origen

    DELETE Picking_Cajas_Disp WHERE Id_Producto IN (SELECT I.ID_PRODUCTO FROM Picking_Cbtes_Items I, Picking_Cbtes C
           WHERE I.ID_TRANS = C.ID_TRANS AND C.ID_TRANS = @id_trans_origen)
