How do I remove characters from my data in SQL 2005

Posted on 2011-10-05
Last Modified: 2012-05-12
I'm trying to remove the SMTP: prefix from my column. How do I do this?
UPDATE EmpDetails

SET MgrEmail = REPLACE(MgrEmail, SUBSTRING(MgrEmail, PATINDEX('SMTP:', MgrEmail), 1), '')

WHERE PATINDEX('SMTP:', MgrEmail) <> 0
Question by:Annette Wilson, MSIS
    LVL 21

    Accepted Solution

    You don't need to do all of that.  You can simply do this.

    UPDATE EmpDetails
    SET MgrEmail = REPLACE(MgrEmail, 'SMTP:', '')

    This will remove any SMTP: strings from anywhere in the data in that column.



    Author Closing Comment

    by:Annette Wilson, MSIS
    Thank you!

    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

    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

    728 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

    17 Experts available now in Live!

    Get 1:1 Help Now