DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: Help in Update Statement

  1. #1
    Join Date
    Oct 2002
    Posts
    284

    Help in Update Statement

    Hello everyone..

    I need help here in Writing this update statement on a Column 'emailaddr_'. One of our Clients have changed their emai Domain from say abc.com to xyz.com. I need to update all the Rows that abc.com to xyz.com.


    For eg.

    Source Table Column
    --------------------
    [email protected]
    [email protected]


    target Table
    ------------
    [email protected]
    [email protected]


    I have like 950 Records whose email domain needs to be changed.

    Can anyone help me here in Writing a sq ?..

    Any help is appreciated

    Ron

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Cool


    Look at the REPLACE function in sql.
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

  3. #3
    Join Date
    Dec 2000
    Posts
    138
    UPDATE table_name set column_name=replace(column_name,'abc.com','xyz.com')

    Assuming that abc.com comes only as the domain name.

    HTH.

  4. #4
    Join Date
    Feb 2005
    Posts
    158
    And that there isn't a domain with fred_abc.com
    Try
    UPDATE table_name set column_name=replace(column_name,'@abc.com','@xyz.com')
    where substr(column_name,-1*length(@abc.com')) ='@abc.com'

  5. #5
    Join Date
    Oct 2002
    Posts
    284

    Thumbs up

    thanks a lot guys....appreciate it.

    Ron

  6. #6
    Join Date
    Jun 2005
    Location
    London, UK
    Posts
    159
    Quote Originally Posted by gamyers
    where substr(column_name,-1*length(@abc.com')) ='@abc.com'
    I think that is the same thing as

    WHERE column_name LIKE '%@abc.com'

  7. #7
    Join Date
    Feb 2005
    Posts
    158
    The LIKE should be fine in this context.
    Generally, I prefer to use an equals because there's the potential for the contents of a variable to include LIKE wildcard characters (_ and %) which can confuse the result
    EG
    SELECT * from table(sys.dbms_debug_vc2coll ('@test.com','@tast.com','@t_st.com'))
    where column_value like '%@t_st.com'

    However, I did a quck check and these characters shouldn't be in the domain name so the issue should not arise

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width