Solved

SQL Query to search for field containing specific email address

Posted on 2011-03-22
4
306 Views
Last Modified: 2012-05-11
I need a query to search for a specific email address in a table called "dbo.Faults", in a column called "symptom2". The email address is only part of the "symptom2" column. The symptom2 column is set to (ntext,null)

How do I write this query?

AND (if it's easy enough to do) can I search for the email address and replace it with another?

Thanks...
0
Comment
Question by:Chris Millard
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Roman Gherman earned 500 total points
ID: 35190974
SELECT *
FROM dbo.Faults
WHERE symptom2 like '%myEmail@dot.com%'

The replacement requires more thinking
0
 
LVL 9

Assisted Solution

by:Roman Gherman
Roman Gherman earned 500 total points
ID: 35190998
And here is the replacement


Update dbo.Faults
Set    symptom2 = replace(symptom2 , 'myEmail@dot.com', 'myNEWEmail@dot.com')
0
 
LVL 17

Author Closing Comment

by:Chris Millard
ID: 35191009
Perfect - thanks ever so much...
0
 
LVL 8

Expert Comment

by:Kobe_Lenjou
ID: 35191013
And combined (to be a bit friendly to SQL Server):

Update dbo.Faults
Set    symptom2 = replace(symptom2 , 'myEmail@dot.com', 'myNEWEmail@dot.com')
WHERE symptom2 like '%myEmail@dot.com%'
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 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