Solved

Find and Replace in table within SQL Server Mangament 2005

Posted on 2007-04-02
3
184 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In this article I will describe the Copy Database Wizard 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.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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.

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now