Someone entered a ton of numeric data into a table with the sign backwards.
Is there a clean way to flip the sign in the numeric column with a SQL statement?
Someone entered a ton of numeric data into a table with the sign backwards.
Is there a clean way to flip the sign in the numeric column with a SQL statement?
It should be straightforward.
update table set column = -column;
UPDATE [table] SET [column]=[column]*(-1)
You can add a WHERE clause as needed to limit which rows you are flipping signs on.
UPDATE MyTable
SET amount = -amount
WHERE amount = ABS(amount)
By including the amount = ABS(amount) clause you prevent unnecessary log activity and index maintenance. It's always a good idea to only update the rows that actually need it.