find replace text in sql 2005 database

Posted on 2014-08-18
Last Modified: 2016-06-11
I have a db that I need to find /replace some email addresses.  In my example, lets say the db name is db1, the name of the table is dbo.people, and the field is email.  I need to change all email addresses that contain to @

What type of sql statement do I have to make to make this update?
Question by:colonialiu20
    LVL 34

    Accepted Solution

    UPDATE db1.dbo.people
    SET email = REPLACE(email, '', '')
    WHERE email LIKE ''
    LVL 14

    Assisted Solution

    by:Vikas Garg

    Please try this code

    UPDATE db1.dbo.people
    SET email = STUFF(email, CHARINDEX('',email , 1), LEN(''), '')
    WHERE email LIKE '' 

    Open in new window


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now