Sunday, 15 September 2013

sql server 2008 - SQL error "Invalid length parameter passed to the LEFT or SUBSTRING function" -



sql server 2008 - SQL error "Invalid length parameter passed to the LEFT or SUBSTRING function" -

i'm getting sql error

invalid length parameter passed left or substring function

and appears come returned values 14 characters in length.

the our outstanding share values securities feed. instance, value such 195461597.62 m we're trimming off .62 m , multiplying 1000, values 14 or more characters returns invalid length parameter passed left or substring function error, if remove 1 character value runs fine.

this field set data_length of 100 , front end end application value displays set 30 characters, not sure errors telling me.

here's sql:

select udf_char15, (convert(int,(substring(ltrim(rtrim(udf_char15)),0,len(udf_char15) - 5)))*1000) csm_security_cust udf_char15 not null

any help appreciated.

you utilize position of decimal create length agnostic;

select cast(left(udf_char15, charindex('.', udf_char15) - 1) int)

sql-server-2008

No comments:

Post a Comment