Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Chaning a negative value to positive

Author  Topic 

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2006-07-26 : 03:26:07
hi

How do i change a negative value stored in numeric data type to a positive value. I don't seem to find any function that can do this. Thanks

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-07-26 : 03:29:14
Multiply by -1


Declare @num numeric
set @num = -1
Select @num
Select @num * -1


Chirag
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-07-26 : 03:30:29
SELECT ABS(Number) FROM table
SELECT Number * -1 FROM table

UPDATE table SET Number = ABS(Number) WHERE Number < 0
UPDATE table SET Number = Number * -1 WHERE Number < 0

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page
   

- Advertisement -