Reversing Numbers - Microsoft SQL / MS SQL Server

Is there a function that will turn a -50 into 50 and 50 into -50? I am familier with ABS, but ABS turns everthing to positive, I just want to revers the signs. Thanks...

1. Reversing Numbers

Is there a function that will turn a -50 into 50 and 50
into -50? I am familier with ABS, but ABS turns everthing
to positive, I just want to revers the signs.

Thanks
borr Guest

2. Re: Reversing Numbers

multiply the number by -1
Ex:
declare x int
select x = -1
select x = (x * -1)
print x

--
-Vishal

"borr" <bdorr39hotmail.com> wrote in message
news:041901c34722\$1a1d16c0\$a301280aphx.gbl...
> Is there a function that will turn a -50 into 50 and 50
> into -50? I am familier with ABS, but ABS turns everthing
> to positive, I just want to revers the signs.
>
> Thanks

Vishal Parkar Guest

3. Re: Reversing Numbers

MyValue * -1

"borr" <bdorr39hotmail.com> wrote in message
news:041901c34722\$1a1d16c0\$a301280aphx.gbl...
> Is there a function that will turn a -50 into 50 and 50
> into -50? I am familier with ABS, but ABS turns everthing
> to positive, I just want to revers the signs.
>
> Thanks

4. Re: Reversing Numbers

How about just multiplying it by -1?

-50 * -1 = 50
50 * -1 = -50

Bob Castleman
SuccessWare Software

"borr" <bdorr39hotmail.com> wrote in message
news:041901c34722\$1a1d16c0\$a301280aphx.gbl...
> Is there a function that will turn a -50 into 50 and 50
> into -50? I am familier with ABS, but ABS turns everthing
> to positive, I just want to revers the signs.
>
> Thanks

Bob Castleman Guest

5. Re: Reversing Numbers

How about just multiply by minus 1?

Mike John

"borr" <bdorr39hotmail.com> wrote in message news:041901c34722\$1a1d16c0\$a301280aphx.gbl...
> Is there a function that will turn a -50 into 50 and 50
> into -50? I am familier with ABS, but ABS turns everthing
> to positive, I just want to revers the signs.
>
> Thanks
Mike John Guest

6. Re: Reversing Numbers

SELECT CASE YourCol WHEN < 0 THEN ABS(YourCol) ELSE YourCOl * -1 END

--

Andrew J. Kelly
SQL Server MVP

"borr" <bdorr39hotmail.com> wrote in message
news:041901c34722\$1a1d16c0\$a301280aphx.gbl...
> Is there a function that will turn a -50 into 50 and 50
> into -50? I am familier with ABS, but ABS turns everthing
> to positive, I just want to revers the signs.
>
> Thanks

Andrew J. Kelly Guest

7. Reversing Numbers

How about the formula: (0 - 50)

>-----Original Message-----
>Is there a function that will turn a -50 into 50 and 50
>into -50? I am familier with ABS, but ABS turns
everthing
>to positive, I just want to revers the signs.
>
>Thanks
>.
>
Guest

8. Reversing Numbers

I meant,

select 0 - (-50) = 50
select 0 - (50) = -50
>-----Original Message-----
>Is there a function that will turn a -50 into 50 and 50
>into -50? I am familier with ABS, but ABS turns
everthing
>to positive, I just want to revers the signs.
>
>Thanks
>.
>
Sagar Guest

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•