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

x
?
Solved

stored procedure find and replace text in column

Posted on 2010-01-05
5
Medium Priority
?
287 Views
Last Modified: 2012-05-08
I'm guessing that it is possible to do this but I do not know how.  What I want to do is scan a text column, find a certain word in the text (not case sensitive if possible) and then insert text in a different column in the same table.  So, If column A contains the word "test" insert the word "boobs" in column B.  If you know how to do this please let me know!
0
Comment
Question by:schwientekd
5 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 26187329
Hello schwientekd,

 update tablename
 set b = 'boobs'
 where  charindex('test', a)  >0

Regards,

aneeshattingal
0
 
LVL 5

Expert Comment

by:dbidba
ID: 26187513
You mention that it is a text column. It the column is truely a "text" datatype, the charindex() function is not allowed and you should change it to varchar(max) first.
0
 
LVL 6

Expert Comment

by:aymoon80
ID: 26188914
you can use this:

UPDATE YourTable
       SET ColumnB = CASE WHEN (ColumnA like '%YourWordToFind%') THEN 'test' END
0
 
LVL 6

Accepted Solution

by:
aymoon80 earned 2000 total points
ID: 26188921
or
UPDATE YourTable
       SET ColumnB = 'test'
WHERE ColumnA like '%YourWordToFind%'

0
 

Author Closing Comment

by:schwientekd
ID: 31673316
This was exactly what I was looking for.  Easy to follow and worked perfectly!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

873 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