Results 1 to 3 of 3

Thread: substring, patindex?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617
    Hi!

    I have name fields in a table
    like
    Bond James
    Want to wipe out James

    select name from table where ???????

    Any help is appreciated...

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105


    select name from table where name like "Bond *"

    -or-

    select name from table where name like "Bond %"

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    Thanks

    The problem was I had to do it on all the names on the table

    But the solution I came up with
    was

    select name = substring(ltrim(name),1,PATINDEX("% %",ltrim(name)))
    where patindex("% %",name) > 0

    removes text following a space from the name
    while ignoring leading spaces (in fact it removes them as well)

    Thanks again

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