Solved

how to replace text within a string of a specified column

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In this article I will describe the Backup & Restore 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.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

744 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

14 Experts available now in Live!

Get 1:1 Help Now