[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL Query to search for field containing specific email address

Posted on 2011-03-22
4
Medium Priority
?
315 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 2000 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 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

834 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