Reputation: 504
I am getting the below error
Msg 8115, Level 16, State 6, Line 5< br> Arithmetic overflow error converting varchar to data type numeric.
This is sample DDL that illustrates my issue. How would a query be set-up that can achieve such?
Declare @Teetotal As Table (ramalad varchar(500))
Insert Into @Teetotal (ramalad) Values ('200.4'), ('300.12')
Select ramalad
,ManipulatedData = CAST(ramalad AS DECIMAL(16,2)) + ' - ' + (CAST(ramalad As DECIMAL(10,2))/25)*3
FROM @Teetotal
Upvotes: 0
Views: 83
Reputation: 1886
This happens because you're trying to add a string to a decimal:
CAST(ramalad AS DECIMAL(16,2)) + ' - '
SQL does not know how to convert ' - '
to a number, so it raises an error.
Maybe what you want is:
ManipulatedData = ramalad + ' - ' + CAST( (CAST(ramalad As DECIMAL(10,2))/25) *3 as varchar)
Upvotes: 1