sql - Catching last datetime after update wont result -


i have following code:

update sm  set  sm_fecha_venc = (select min(nd_fecha_venc) [db_facturacion].[dbo].[tb_notas_debito]                              sm_codigo = nd_num_servicio                             -- , nd_referencia = sm_cod_producto                                 , nd_num_factura = sm_cod_factura                                  , nd_estado = 'g')     ,sm_fecha_ult_pago = (select max(nd_fecha_pago) [db_facturacion].[dbo].[tb_notas_debito]                              sm_codigo = nd_num_servicio                             -- , nd_referencia = sm_cod_producto                                 , nd_num_factura = sm_cod_factura                                  , nd_estado = 'c')      ,sm_fecha           = getdate()     ,sm_cod_factura_ren = @i_num_factura     output deleted.sm_fecha_venc      fecha_venc_old,           deleted.sm_fecha_ult_pago  fecha_ult_pago_old,           deleted.sm_fecha           fecha_old,           deleted.sm_cod_factura_ren cod_factura_ren_old     @tablatabla -- [db_facturacion].[dbo].[tb_servicios] sm --with(nolock) inner join #servicios t  on sm_codigo = num_servicio sm_tipo_bien_protegido = 1 , [sm_estado] = 1 --and sm.sm_cod_forma_contrato = 1 , sm.sm_tipo_inventario = tipo_inventario    /*===========================        inserted deleted  =============================*/  update db_facturacion.[dbo].[tb_log_cambio_servicio] set         cs_fecha_venc_old        = fecha_venc_old            ,cs_fecha_ult_pago_old    = fecha_ult_pago_old                                                          ,cs_fecha_old             = fecha_old            ,cs_cod_factura_ren_old   = cod_factura_ren_old @tablatabla         cs_codigo = @id_ultimo_ing  (last @@identity) 

im trying save last dates log table, in case have return dates back.

the code works good, it's catching actual date , inserted in log table.

what missing?


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -