JustATheory
IS-IT--Management
Greetings,
I have a column that displays weight, I need to strip out "lb" and convert it to a numeric or decimal (3,1). the column needs to be averaged, all is fine until the conversion, and I keep getting an error.
Msg 8115, Level 16, State 8, Line 96
Arithmetic overflow error converting nvarchar to data type numeric.[/highlight]
Can this be done in one statement? I have 10 columns with similar requirements. Please help!
Thanks you,
Weight
- -
230.2lb
220.2lb
SELECT
CAST(case when Weight = '- -' then NULL else REPLACE(Weight, 'lb', '') END as NUMERIC(3,1)) AS TEST
I have a column that displays weight, I need to strip out "lb" and convert it to a numeric or decimal (3,1). the column needs to be averaged, all is fine until the conversion, and I keep getting an error.
Msg 8115, Level 16, State 8, Line 96
Arithmetic overflow error converting nvarchar to data type numeric.[/highlight]
Can this be done in one statement? I have 10 columns with similar requirements. Please help!
Thanks you,
Weight
- -
230.2lb
220.2lb
SELECT
CAST(case when Weight = '- -' then NULL else REPLACE(Weight, 'lb', '') END as NUMERIC(3,1)) AS TEST