Reputation: 23
Using SQL 2014 I need to append a negative sign to a list of numeric values. The data are dollar amounts with numerous places behind the decimal point. I did convert the data to numeric(15, 2)
Here is my select statement.
SELECT '-' + convert(15,2), MONEY from TABLE
I am getting the error: Arithmetic overflow error converting varchar to data type numeric.
I tried converting to varchar as well.
select '-' + CONVERT(varchar10), (convert(numeric(15, 2), MONEY)) from
TABLE
I get the same error as above. Any ideas how to accomplish this?
Upvotes: 1
Views: 3160
Reputation: 37338
why not trying Cast Function
SELECT -1 * CAST(MONEY as Numeric(15.2)) from TABLE
Upvotes: 0
Reputation: 1270311
How about multiplying by -1 instead? Something like this:
SELECT -1 * convert(MONEY, 15.2) from TABLE
Your syntax isn't correct. I am guessing you want something like the above.
Or subtract from 0.
Upvotes: 1