To cut both, leading and trailing blanks, you should use ALLTRIM(). TRIM() is identical to RTRIM(), so it cuts off only right (trailing) spaces, which are not likely to happen when you use STR() on a numeric value. I guess, LTRIM() would be enough in your case. Is that what you mean under "not working"?
You mean, you are updating numeric field with the same value, only converted to string? That's you type mismatch. Even if you turn it back to numeric with VAL(), the actual value isn't going to change.
UPDATE is supposed to be used for value change, not the size of the field. If you need to reduce the size of your numeric field, you should probably use ALTER TABLE.
But it's numeric, isn't it? Numeric cannot have any "blanks". The actual value is the same whether the field is filled "to the capacity" or has a few places to spare. What is it you are actually trying to do?
Well, what I did earlier is updated this field to a numeric 2 instead of numeric 10 and my values erased - maybe it was a glitch - I'll try again Thank you
Our posts crossed again. Your field was cut to N(2) because your first value in the field was a 2-digit number. If you trying to reduce the number of numeric positions to, say, 5 instead of 2, try padding the value:
UPDATE r00_test SET ups_active = VAL(PADL(ALLTRIM(STR(UPS_active)),5,'0')
But I would use ALTER TABLE instead.
If reducing the field size is not what are you trying to do, then what?
Please confirm that your field is numeric and not string containig numeric characters. If it is, what are you trying to do and what you mean by leading blanks and why do you want them out?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.