Replace or Update partial field

  • I need to replace or update email addresses.  The address is in one field. 

    Example:  emailname@emailaddress.net

    Many (not all) of the emailaddress.net need to be replaced with a new email address. The email name needs to remain.

    This is what I tried but I have something wrong.

    SELECT = replace('emailaddress.net', 'emailaddress.net', '%@newaddress.net')

    Then I tried this -

    UPDATE dbo.tablename

    SET email_address = %'@emailaddress.net'

    WHERE email_address LIKE '%@newaddress.net'

    I think I changed everyone's name to % with one of these.  I at least am working on a copy of the database - and I am skilled and restoring my copy!!

    Any help would be great!


    Kindest Regards,

    Tammy

  • Update dbo.tablename

    SET email_address = Replace(email_address, '@emailaddress.net', '@newemailaddress.net')

    Syntax:

    REPLACE(string, , )

    Before you do an UPDATE, you can do a SELECT

    SELECT email_address , Replace(email_address, '@emailaddress.net', '@newemailaddress.net')

    FROM dbo.TableName

    to see which rows get updated.

    ******************
    Dinakar Nethi
    Life is short. Enjoy it.
    ******************

  • SELECT email_address , Replace(email_address, '@emailaddress.net', '@newemailaddress.net')

    FROM dbo.TableName

     

    This delivers all email addresses not just the email addresses ending in emailaddress.net.  20,000 emails vs 2,000.  I messed around with it a bit and I am still doing something wrong.

    More help needed - please.


    Kindest Regards,

    Tammy

  • SET email_address = Replace(email_address, 'emailaddress.net', 'newemailaddress.net')

    Gives this errorLine 1: Incorrect syntax near '='.


    Kindest Regards,

    Tammy

  • IT WORKED!!

    update tel_tldiremp

    SET email_address = Replace(email_address, 'emailaddress.net', 'newemailaddress.net')

     

    IT WORKED!!!

    THANK YOU!!  IT WORKED!


    Kindest Regards,

    Tammy

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

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