Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Location
    Tokyo
    Posts
    6

    Question Unanswered: measuring string lengths

    I have been try to figure out how to measure the length of a string with Sybase.

    If, for example, I have a table that has it columns difined as ...

    No int,
    Name varchar(10)

    No Name
    1 paul
    2 john
    3 george
    4 ringo

    ...then using datalength(Name) with Sybase ASE 12.5 will return 4,4,6,5 as the lengths for the data of each row in my table. However, if Name is defined not as a varchar(10), but rather as a char(10), then all I am able to get back is 10,10,10,10.

    I have tried len(Name), but it does not work with Sybase ASE 12.5.

    What other ways are there to measure the length of strings in a non-varchar field?

  2. #2
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    What about datalength( rtrim( your_col ) ) ?
    Thanks,

    Matt

  3. #3
    Join Date
    Oct 2002
    Location
    Tokyo
    Posts
    6
    Originally posted by MattR
    What about datalength( rtrim( your_col ) ) ?
    Worked wonders! The tought of trimming the spaces at the end of the string
    never crossed my mind. Thanks much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •