Solved

how to replace text within a string of a specified column

Posted on 2011-02-19
3
264 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

734 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