Update to several records

0
  

I want to update all the records of a table (tbl_DepresacionesUmas) where the status is different to low but when doing that, it returns more than one value and generates an error, how can I solve that in sql?

    Update Tbl_DepresacionesUmas
set ValorActual =ValorInicial
where Estatus != 'Baja'

Update Tbl_DepresacionesUmas
set Dias = ( DATEDIFF(Day,Fecha_Inicio, GETDATE()))
where Estatus != 'Baja'
    
asked by JT25 14.08.2018 в 21:49
source

2 answers

0

already tried with the following way

 Update Tbl_DepresacionesUmas
set ValorActual =ValorInicial,
Dias = ( DATEDIFF(Day,Fecha_Inicio, GETDATE()))
where Estatus != 'Baja';
    
answered by 14.08.2018 в 21:51
0

Try this way, you will update according to the cycle that you are using each record that meets the condition:

UPDATE Tbl_DepresacionesUmas
SET ValorActual = ValorInicial, Dias = (DATEDIFF(DAY,Fecha_Inicio, GETDATE()))
WHERE Estatus NOT IN ('Baja');
    
answered by 14.08.2018 в 22:26