Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

How do I remove characters from my data in SQL 2005

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
Annette Wilson, MSIS
Annette Wilson, MSIS
1 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.


Annette Wilson, MSISSr. Programmer AnalystAuthor Commented:
Thank you!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now