Results 1 to 5 of 5

Thread: [RESOLVED] trim character function?

  1. #1

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Resolved [RESOLVED] trim character function?

    Is there a function that will trim a designated amount of characters off the right (or left) end of a string? I'm using sql server 2005.

    Thanks!
    Last edited by drpcken; Nov 10th, 2006 at 12:01 AM.

    In the unlikely event that I answer your question correctly, please Rate my post

    Using Visual Studio 2005 Professional

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: trim character function?

    If Im not wrong SubStr or SubString is the function to extract specific chars from a given string...its equivalent to Mid function is vb...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3

    Thread Starter
    Fanatic Member drpcken's Avatar
    Join Date
    Apr 2004
    Location
    devenv
    Posts
    591

    Re: trim character function?

    excellent! I used the substring category to start from the beginning, then got the length of the string and subtracted the number of characters i wanted to cut off.

    Code:
    select substring(field, 1, len(field) -2)) from table
    Thanks!

    In the unlikely event that I answer your question correctly, please Rate my post

    Using Visual Studio 2005 Professional

  4. #4
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: [RESOLVED] trim character function?

    you are most welcome...
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [RESOLVED] trim character function?

    Just an FYI, there is also a Left (and Right) function:
    Code:
    select Left(field, len(field) -2)) from table
    ..it may be faster, but I'm not sure.

Posting Permissions

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



Click Here to Expand Forum to Full Width