Solved

how to replace text within a string of a specified column

Posted on 2011-02-19
3
265 Views
Last Modified: 2012-08-13
How can I replace a string "2011-02-05" (right 10 characters) in every row of my column called unique?  I need to replace this with "2011-01-29' .  Not every field has the same number of characters.

0
Comment
Question by:kat50
[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 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 34934005
UPDATE SomeTable
SET SomeColumn = REPLACE(SomeColumn, '2011-02-05', '2011-01-29')
WHERE CHARINDEX('2011-02-05', SomeColumn) > 0
0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 500 total points
ID: 34934010
To work specifically on the right 10 chars...

UPDATE SomeTable
SET SomeColumn = SUBSTRING(SomeColumn, 1, LEN(SomeColumn) - 10) + '2011-01-29'
WHERE SomeColumn LIKE '%2011-02-05'
0
 

Author Closing Comment

by:kat50
ID: 34934013
Thank you
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
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
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

718 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