• anushakadiyala 52521 (12/17/2013)


    Thank you for taking a look, This is the code I have been trying.

    UPDATE TA

    SET ServerName= REPLACE(ServerName, '%.%.dim.com', '')

    WHERE Servername like '%.%.dim.com%'

    You cannot use wildcards in a REPLACE.

    basically I want to remove anything that starts with first "."

    The following should do as you ask... I don't know how you operate but I recommend not just blindly using this. Lookup the functions in Books Online (press the {f1} key in SSMS to get there) and teach yourself how they work and why. 😉

    UPDATE dbo.TA

    SET ServerName = SUBSTRING(ServerName,1,CHARINDEX('.',ServerName)-1)

    WHERE ServerName LIKE '%.%'

    ;

    --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)