Solved

Find and Replace in table within SQL Server Mangament 2005

Posted on 2007-04-02
3
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

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…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

726 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