I need to populate a numeric field hours with data from a varchar string s. To do this, I use the following code, which is contained within an INSERT statement:
This works UNLESS the number I read out of the string is negative, in which case I get an error "Error converting varchar to numeric".
Ideas, anyone?
TIA,
MMund
Code:
hours = convert(numeric(7,2),replicate('0',7 - len(ltrim(substring(s,14,7))))+ltrim(substring(s,14,7)))
This works UNLESS the number I read out of the string is negative, in which case I get an error "Error converting varchar to numeric".
Ideas, anyone?
TIA,
MMund