问题
I have a problem converting from a varchar '000000113754' to decimal 1137.54
I'm comparing two expressions:
1. select STUFF('000000113754', LEN('000000113754') - 1, 0, '.')
2. select STUFF([dbo].fn_PrepareNumeric(('000000113754' + '-'), '+','-'), LEN('000000113754') - 1, 0, '.')
The function fn_PrepareNumeric
just checks for the sign and appends '-' in front if the sign is -
. That's all.
The problem is that the first expression gives me the correct varchar - 0000001137.54
, and the second one does not: -000000113.754
Cannot figure out why?
来源:https://stackoverflow.com/questions/61085924/how-to-convert-varchar-to-decimal38-2