Update Statement

  • Hi

    I have table A, with (Id, Access and ReportPath) columns. I want to update ReportPath column. But now this column have different Paths, all of them starting with /AWB/... So I want to know if is it possible to update all of the records in this Column, by inserting /Development before /AWB/ to have /Development/AWB/, by just one Update statment? I hope I'm clear.

    e.g

    /AWDBI/WORK RECEIVED/AGE ANALYSIS/DETAILS; /AWDBI/WORK IN PROGRESS/AGE ANALYSIS; /AWDBI/SECTION 14/WORK FINALISED

    and many other more Paths, So I want to change these Paths to:

    /Development/AWDBI/WORK RECEIVED/AGE ANALYSIS/DETAILS;/Development /AWDBI/WORK IN PROGRESS/AGE ANALYSIS; /Development/AWDBI/SECTION 14/WORK FINALISED

    So is it possible to change that in just one Update Statement/

  • hoseam (7/28/2014)


    Hi

    I have table A, with (Id, Access and ReportPath) columns. I want to update ReportPath column. But now this column have different Paths, all of them starting with /AWB/... So I want to know if is it possible to update all of the records in this Column, by inserting /Development before /AWB/ to have /Development/AWB/, by just one Update statment? I hope I'm clear.

    e.g

    /AWDBI/WORK RECEIVED/AGE ANALYSIS/DETAILS; /AWDBI/WORK IN PROGRESS/AGE ANALYSIS; /AWDBI/SECTION 14/WORK FINALISED

    and many other more Paths, So I want to change these Paths to:

    /Development/AWDBI/WORK RECEIVED/AGE ANALYSIS/DETAILS;/Development /AWDBI/WORK IN PROGRESS/AGE ANALYSIS; /Development/AWDBI/SECTION 14/WORK FINALISED

    So is it possible to change that in just one Update Statement/

    Please please please one of these times post some details in your question. We can't see your screen, we have no idea what your tables look like and we have no idea what you are trying to do.

    In order to help we will need a few things:

    1. Sample DDL in the form of CREATE TABLE statements

    2. Sample data in the form of INSERT INTO statements

    3. Expected results based on the sample data

    Please take a few minutes and read the first article in my signature for best practices when posting questions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • update <<tablename>>

    set path = replace('/AWDBI/', '/Development/AWDBI/', path)

    If you have multiple things that need to be replaced you can have more than one.

    update <<tablename>>

    set path = replace('/AWB/', '/Development/AWB/', replace('/AWDBI/', '/Development/AWDBI/', path))

Viewing 3 posts - 1 through 2 (of 2 total)

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