Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strings and multiplication

Status
Not open for further replies.

Chumley40

Programmer
Jan 24, 2005
71
US
I am trying to take a weight that is stored as grams and change it to lbs, then kg, then take height which is stored as cm and show as cm and ft all in one field. It all has to be converted to a varchar 255 field. This is what I have

FormValue=(select case di.code
when 'CombinedMeasurements' then (Select
convert (varchar,convert (float,value), 0) from CV3OrderUserData where userdatacode = 'weight'and CV3OrderuserData.OrderGuid = o.guid and CV3OrderuserData.Clientguid = o.clientguid
) + 'kg ' + (Select
convert (varchar,convert (float,value), 0) from CV3OrderUserData where userdatacode = 'weight'and CV3OrderuserData.OrderGuid = o.guid and CV3OrderuserData.Clientguid = o.clientguid

The problem is, when I place *2.2 in the second select statement I get an error converting numeric to varchar error in sql. Can someone guide me?
)
 
Also, when I put the 2.2 directly after the value, I get the following error:
Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.
 
what is the datatype of value?

If integer then, get rid of the convert(float...) part, do the calculation first and then convert the value to varchar.

Also, Do the query below return any rows?
Code:
select * 
from   yourtable
where  isnumeric(value) = 0

Regards,
AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top