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
 General SQL Server Forums
 New to SQL Server Programming
 Remove negative signs

Author  Topic 

Weekend
Starting Member

20 Posts

Posted - 2007-07-25 : 07:06:48
Hi

I have values in col_A (smallint) as follows.

1
-4
3
6
-7

I want the negative to be remove and result as follows.

1
4
3
6
7

Please advise how?

Thanks
Jawad

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-07-25 : 07:07:56
Select ABS(col_A) from tablename

--------------------------------------------------
S.Ahamed
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-07-26 : 01:48:50
Hello pbguy,
I've updated the values of a table with this abs like this
initially the records are like this
name credit
A -9
B -8
c -5

now i've updated the table like this

update mytable set credit=abs(credit)

now the values are like this

name credit
A 9
B 8
c 5

is it now possible to change all the values with - again?

thank you very much...


Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

pbguy
Constraint Violating Yak Guru

319 Posts

Posted - 2007-07-26 : 01:55:48
Waht is the problem?

update mytable set credit=(-1)*credit


--------------------------------------------------
S.Ahamed
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-07-26 : 02:04:14
ohhhhhhhhhhhhhh
sorry
that's really my foolish

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page
   

- Advertisement -