[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 26
  • Last Modified:

find replace text in sql 2005 database

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 @example.com to @ test.org.

What type of sql statement do I have to make to make this update?
0
colonialiu20
Asked:
colonialiu20
2 Solutions
 
Brian CroweCommented:
UPDATE db1.dbo.people
SET email = REPLACE(email, '@example.com', '@test.org')
WHERE email LIKE '%@example.com'
0
 
Vikas GargBusiness Intelligence DeveloperCommented:
Hi,

Please try this code

UPDATE db1.dbo.people
SET email = STUFF(email, CHARINDEX('@example.com',email , 1), LEN('@example.com'), '@test.org')
WHERE email LIKE '%@example.com' 

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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