relpace portion of string in table

  • i have a table with a column that has links. ie "http://xyz.com/custom/app1.asp"

    i need to modify all records with xyz.com to be

    "http://localhost/custom/app1.asp"

    how can i do this?

    thanks

    jim

  • This worked for me

    DECLARE @test-2 VARCHAR(50)

    SET @test-2 = 'http://xyz.com/customer/app1.asp'

    SELECT REPLACE(@test, 'xyz.com','localhost')

  • Thank you for your response. How do I update the table with this?

    thanks

    jim

  • I have found a solution. Thanks for the help.

    Jim

  • jim.rasmussen (8/27/2009)


    I have found a solution. Thanks for the help.

    Jim

    2 way street here, Jim. Please post the solution you found. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Here is what I came up with..

    UPDATE TBLNAME SET COLNAME = REPLACE(COLNAME, 'xyz.com', 'localhost')

    WHERE COLNAME LIKE '%xyz.com%'

    Jim

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply