Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Find and Replace in table within SQL Server Mangament 2005

Posted on 2007-04-02
3
Medium Priority
?
239 Views
Last Modified: 2010-03-19
Hi, I am working with a table in Microsoft SQL Server Management 2005. I have a nvarchar(254) field where I need to find and replace part of the text and I am not sure how to do this.

Example: This Print on Demand Classic, originally published in 1948, discusses abnormal personality in a way to make it interesting to students new to the subject.

NEEDS to BE this Below:
This Print-on-Demand book, originally published in 1948, discusses abnormal personality in a way to make it interesting to students new to the subject.

Any suggestions on how to replace "Print on Demand Classic" to "Print-on-Demand book" would be great.

Thanks :-)
0
Comment
Question by:Mamea
  • 2
3 Comments
 
LVL 11

Expert Comment

by:dready
ID: 18840680
Try this. I assumed your table is called myTable, and that the text is in the column title.

update myTable set title = replace(title, 'Print on Demand', 'Print-on-Demand')

0
 
LVL 11

Accepted Solution

by:
dready earned 2000 total points
ID: 18840692
or, to be more precise:

update myTable set title = replace(title, 'Print on Demand Classic', 'Print-on-Demand book')



0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18840862
Or to be more efficient (no points please):
Update myTable
Set title = REPLACE(title, 'Print on Demand Classic', 'Print-on-Demand book')
Where CHARINDEX('Print on Demand Classic', title) > 0

:)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

971 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