sql server - Invalid length parameter passed to the RIGHT function -


about 2 weeks ago sql has been working past 6 months started throwing error without changing. spent couple days trying find out going on , did not make sense.

eventually, tried "alter" on stored procedure (which had no effect) , dropped , recreated (which did fix it).

then, 2 days ago, error came , time drop/create not fixing it. according guys, have not patched sql servers in 1.5 months there nothing changed there. have ideas or has had same issues?

this line of code, in stored procedure:

select labeltext + data cu_formlayout fl     inner join cu_data dat on dat.layoutid = fl.id     cross apply (select right(fl.xlabeltext,1) rightchar) ca2     cross apply (select case when ascii(rightchar) between 49 , 57 or                                  ascii(rightchar) between 65 , 90 or                                  ascii(rightchar) between 97 , 122                             fl.xlabeltext + ': '                             else fl.xlabeltext + ' ' end labeltext) ca1 

causes error:

invalid length parameter passed right function.

as can see, right() has hard-coded length. how invalid?

btw, point of code takes "label" 1 column , if ends letter or number, add ": " , data value label for. other-wise put space between them.

perhaps if can't find cause (it's bugging production environment), rewrite using substring? or combination of reverse & left.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -