I have the following query :
Valor1 = '200.000,00';
select Valor1 from TB1
Is there a function that converts a positive number to negative?
I have the following query :
Valor1 = '200.000,00';
select Valor1 from TB1
Is there a function that converts a positive number to negative?
If you just want to select the values as negative, it looks like this:
select -CAST(REPLACE(REPLACE(Valor1, '.', ''), ',', '.') AS DECIMAL(10, 2)) from TB1
or
select -1 * REPLACE(REPLACE(Valor1, '.', ''), ',', '.') from TB1
If you want to change them in the table:
update TB1 set Valor1 = -1 * REPLACE(REPLACE(Valor1, '.', ''), ',', '.')
Pure mathematics, except for conversion. It would be good to rethink whether to use a type that requires conversion. Look at the confusion you will have to make in every consultation. It's best to start fixing these things to avoid future problems.
Multiply by -1 that the multiplication result is the negative number.
select Valor1 * -1 AS Valor1 from TB1