Solved

Replace a string based on a value in another field

Posted on 2012-03-15
2
340 Views
Last Modified: 2012-03-15
I want to update the FullDescription field based on a value in the Name field :

SELECT Name
FROM  Nop_Product
WHERE (Name LIKE '%(MEN)%')    :

ACQUA DI PARMA by Acqua di Parma (MEN) COLOGNE SPRAY 3.4 OZ

FullDescription field :

<strong>ACQUA DI PARMA by Acqua di Parma</strong> - <span style='font-size:15px;'>Genuine Brand Name Perfume</span><p style='font-size:18px;color:black;padding-top:10px;padding-bottom:10px;'>COLOGNE SPRAY 3.4 OZ</p>Gender : MEN<br /><br />Brand : ACQUA DI PARMA<br /><br />Designer : Acqua di Parma<br /><br />Fragrance : rosemary, citrus, lavender

I want to replace the string : 'Genuine Brand Name Perfume' in FullDescription
with                                       'Genuine Brand Name Fragrance'

WHERE the string '(MEN)' is in the field 'Name'


UPDATE [Nop_Product]
SET  FullDescription =

 WHERE

What's the best way to do this? thanks
0
Comment
Question by:MikeMCSD
2 Comments
 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 37725713
This does what you asked:

UPDATE [Nop_Product]
SET  FullDescription =  replace(fulldescription,'Genuine Brand Name Perfume' ,'Genuine Brand Name Fragrance')
WHERE Name LIKE '%(MEN)%'

Now let's see where that's going to take us :>)
0
 
LVL 16

Author Closing Comment

by:MikeMCSD
ID: 37726018
thanks
0

Featured Post

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

733 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