Replacing a portion of text string in column

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Pradip Sagdeo

    Replacing a portion of text string in column

    I need to replace a portion of a url in a column as a result of
    changing servers. Is there a SELECT/REPLACE/UPDATE combination query
    that can do this. The table has close to a thousand entries and would
    be nice if a query can be set to do this. Tried the REPLACE example
    in the BOOKS ONLINE but it creates syntax error, apparently because it
    does not like the characters in the url and/or wildcards. I don't need
    to replace the entire url, only the portion before ".com". Thanks in
    anticipation of your help.

    Pradip Sagdeo
  • Chuck Conover

    #2
    Re: Replacing a portion of text string in column

    Pradip,
    This statement:
    select replace('http://www.technicalvi deos.net','s.ne t','s14.net')
    seems to work OK, so, perhaps you could give your exact update and the exact
    error along with some sample data.
    Best regards,
    Chuck Conover




    "Pradip Sagdeo" <pradip.m.sagde o@pfizer.com> wrote in message
    news:8dbc5a0f.0 401280726.708a1 c6@posting.goog le.com...[color=blue]
    > I need to replace a portion of a url in a column as a result of
    > changing servers. Is there a SELECT/REPLACE/UPDATE combination query
    > that can do this. The table has close to a thousand entries and would
    > be nice if a query can be set to do this. Tried the REPLACE example
    > in the BOOKS ONLINE but it creates syntax error, apparently because it
    > does not like the characters in the url and/or wildcards. I don't need
    > to replace the entire url, only the portion before ".com". Thanks in
    > anticipation of your help.
    >
    > Pradip Sagdeo[/color]


    Comment

    • Pradip Sagdeo

      #3
      Re: Replacing a portion of text string in column

      Thanks. I will try again. Must have made a typing mistake.

      Pradip



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Erland Sommarskog

        #4
        Re: Replacing a portion of text string in column

        Pradip Sagdeo (pradip.m.sagde o@pfizer.com) writes:[color=blue]
        > I need to replace a portion of a url in a column as a result of
        > changing servers. Is there a SELECT/REPLACE/UPDATE combination query
        > that can do this. The table has close to a thousand entries and would
        > be nice if a query can be set to do this. Tried the REPLACE example
        > in the BOOKS ONLINE but it creates syntax error, apparently because it
        > does not like the characters in the url and/or wildcards. I don't need
        > to replace the entire url, only the portion before ".com". Thanks in
        > anticipation of your help.[/color]

        Unfortunately, the replace() function does not support wildcards, so
        if you need to use that, you have to be creative. Or descend to use
        some client code to handle it.


        --
        Erland Sommarskog, SQL Server MVP, sommar@algonet. se

        Books Online for SQL Server SP3 at
        Transform your business with a unified data platform. SQL Server 2019 comes with Apache Spark and Hadoop Distributed File System (HDFS) for intelligence over all your data.

        Comment

        Working...