Solved

how to replace text within a string of a specified column

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

813 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

17 Experts available now in Live!

Get 1:1 Help Now