Results 1 to 5 of 5

Thread: UPDATE left _

  1. #1
    Join Date
    Apr 2006
    Posts
    178

    UPDATE left _

    how can I can update a table ::
    I must get all the left part of a columns part1_part2
    I dont know how many characters

    something like :

    UPDATE Users SET Users.Info = left(Users.name, _ ??? or split('_'))



    in that case Users.name = part1

    thank you

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    what RDBMS?
    if it is sql server then you can use LEFT function and CHARINDEX function to do it.

  3. #3
    Join Date
    Apr 2006
    Posts
    178
    yes sorry MS SQL 2000

    I must get all the left chars of '_' but I dont know how many
    if you know how to do it ?

    i must update only the one with a '_' and do nothing for the others

    thank you
    Last edited by anselme; 12-01-2006 at 12:05 PM.

  4. #4
    Join Date
    Dec 2004
    Posts
    502
    UPDATE Users SET Users.Info = LEFT(Users.name, CHARINDEX('_', Users.name) -1)
    WHERE CHARINDEX('_', Users.name) > 0

  5. #5
    Join Date
    Apr 2006
    Posts
    178
    perfect !

    thanks a lot

Posting Permissions

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