Update part of a column with new value

  • I have a need to update part of a column that has a production UNC path to a specific directory file and need to replace it to a test directory path instead

    Table Template_Dir has Column (Template_Path) with "\\SERVER1\Reports\%inc\%report\" value

    I need to just replace \\SERVER1\Reports with "\\NEWSERVER\Reports\%inc\%report\" on any occurence that has \\SERVER1\Reports in the Template_Path Column

    I figured its like UPDATE Template_Dir SET Template_Path = '\\NEWSERVER\Reports\???' WHERE Dept = 'HR'

    I need to maintain the current UNC path after \\NEWSERVER\Reports\ (\%inc\%report) and just change \\SERVER1\Reports\ part of the whole UNC path

    Appreciate help on this newbie update.

  • Peter D (12/4/2008)


    I have a need to update part of a column that has a production UNC path to a specific directory file and need to replace it to a test directory path instead

    Table Template_Dir has Column (Template_Path) with "\\SERVER1\Reports\%inc\%report\" value

    I need to just replace \\SERVER1\Reports with "\\NEWSERVER\Reports\%inc\%report\" on any occurence that has \\SERVER1\Reports in the Template_Path Column

    I figured its like UPDATE Template_Dir SET Template_Path = '\\NEWSERVER\Reports\???' WHERE Dept = 'HR'

    I need to maintain the current UNC path after \\NEWSERVER\Reports\ (\%inc\%report) and just change \\SERVER1\Reports\ part of the whole UNC path

    Appreciate help on this newbie update.

    u can use this

    update tablename set value = Replace('\\SERVER1\Reports\%inc\%report\,'SERVER1','NEWSERVER') where condition

    kshitij kumar
    kshitij@krayknot.com
    www.krayknot.com

  • Like this:

    UPDATE Template_Dir

    SET Template_Path = Replace(Template_Path, '\\SERVER1\Reports', '\\NEWSERVER\Reports\')

    WHERE Dept = 'HR'

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Great thnxs guys for your help.

  • Glad we could help

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Stuff like that shouldn't be hardcoded. It should be in a configuration table.

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

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

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