Solved

convert positive to negative in SQL

Posted on 2014-12-19
4
106 Views
Last Modified: 2014-12-21
How can I convert below number to positive number?

-2650.000000
0
Comment
Question by:VBdotnet2005
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 250 total points
ID: 40510266
ABS (-2650.000000)
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 250 total points
ID: 40510282
The question head mentioned to negative, but its text mentioned positive.

Try: for a number i,
SELECT -(i);

Specific example: -(-2650.000000)
0
 
LVL 37

Assisted Solution

by:Neil Russell
Neil Russell earned 125 total points
ID: 40510538
Or of course multiply by -1 IF you know its always negative.  But if you only ever want a positive and dont know if it will be positive or negative to start with then use hnasr's example of ABS(number).
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 125 total points
ID: 40510935
I'm not sure of what it is you're trying to do, but these commands (some already suggested) will generate the following results:
Multiply by -1 ==> will convert negative to positive and positive to negative
Use ABS() function ==> will always return positive (i.e. converts negative to positive and leaves positive as positive)
Multiply ABS() function by - 1 ==> will always return negative
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now