Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to "flip the sign" of numbers in a table

Status
Not open for further replies.

katbear

Programmer
Mar 14, 2007
270
US
Hi,

I have table where I need to reverse the signs of all the numbers in the table.

e.g)

2,000 needs become -2,000

and

-2,000 needs to become 2,000

Help... do I need a cursor to do this? Or is there an easier way??

Thanks
 
Multiply the values by -1.
Code:
update table
   set Column = Column * -1

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Code:
update table set column = -column

[COLOR=black #d0d0d0]My alarm clock causes time travel. When I hit snooze, no apparent time passes before the alarm sounds again, but the universe has in fact moved forward through time by ten minutes![/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top