Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
170 Points
255 Posts
May 19, 2011 01:49 PM|LINK
I have weight data stored in a SQL Server table as varchar data type. Generally the data is stored like '57.25 kg'. I am trying to extract the 57.25.
This is what I have at the moment:
select convert(numeric, (rtrim(STR(weight,1,(charindex(' ',weight)))))) from ahi_patient where weight is not null and weight <> 0
I am getting the following error:
Syntax error converting the varchar value '79.38 kg' to a column of data type int.
Any suggestions on how to get past this?
thanks
Mongol648
Member
170 Points
255 Posts
Converting String Data
May 19, 2011 01:49 PM|LINK
I have weight data stored in a SQL Server table as varchar data type. Generally the data is stored like '57.25 kg'. I am trying to extract the 57.25.
This is what I have at the moment:
select convert(numeric, (rtrim(STR(weight,1,(charindex(' ',weight)))))) from ahi_patient where weight is not null and weight <> 0I am getting the following error:
Syntax error converting the varchar value '79.38 kg' to a column of data type int.
Any suggestions on how to get past this?
thanks