August 9, 2002 at 10:25 am
I am trying to populate a row with blank spaces at the end of a string like this:
create table t1(
col1 char(15))
insert into t1 values ('abc ')
select len(col1) from t1
3???(I want to see 5)
-Kevin
August 9, 2002 at 3:30 pm
Intersting. Looks like a bug. Tried this and it fails
select
len(col1)
, replace(col1, ' ', 'x')
, len(replace(col1, ' ', '-'))
, col1
from t1
From BOL, len returns the number of characters, not bytes, excluding trailing spaces. You would never get 5 anyway, you'd get 15. If you change to varchar, the len(replace)) will work.
Steve Jones
August 9, 2002 at 3:32 pm
Try like this.
create table t1(
col1 char(15))
insert into t1 values ('abc'+char(9)+char(9))
select len(col1) from t1
drop table t1
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply