Solved

Find and Replace in table within SQL Server Mangament 2005

Posted on 2007-04-02
3
222 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 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

749 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